views:

82

answers:

1

Hi

Is there an equivalent to XmlTextAttribute when using DataContractSerializer?

I want to treate a property as the 'default property when it is serialized to XML. For example:

[Serializable]
[DataContract]
public class Item
{
    [DataMember]
    public String Value
    {
        get;
        set;
    }
}

A object with .Value set to "foo" is serialized as:

<Item>foo</Item>

rather than:

<Item><Value>foo</Value></Item>

Lee

A: 

I don't think you can do that using the DataContractSerializer.

Marc

marc_s