Serialization by DataContract

115 views Asked by At

What attributes I must used for next class (and/or class members):

[DataContract(Namespace = "classNamespace")]
public class TestClass
{

    [DataMember(Name = "fieldName1")]
    public string Field1;

    [DataMember(Name = "fieldName2")]
    public string Field2;

    [DataMember(Name = "fieldName3")]
    public EnumType Filed3;

}

what would this class serialize to next xml:

<TestClass xmlns:a="classNamespace" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" fieldName1="fieldValue1" fieldname2="filedValue2" fieldName3="fieldValue3" />

But not to:

<TestClass xmlns:a="classNamespace" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:fieldName1>fieldValue1</a:fieldName1><a:fieldName2>fieldValue2</a:fieldName2><a:fieldName3>fieldValue3</a:fieldName3></TestClass>
0

There are 0 answers