How do you rename the child XML elements used in an XML Serialized List<string>?

Posted by GrZeCh on Stack Overflow See other posts from Stack Overflow or by GrZeCh
Published on 2008-11-26T20:05:42Z Indexed on 2010/05/20 23:10 UTC
Read the original article Hit count: 205

Filed under:
|
|
|

Hello, I'm serializing to XML my class where one of properties has type List<string>.

public class MyClass {
    ...
    public List<string> Properties { get; set; }
    ...
}

XML created by serializing this class looks like this:

<MyClass>
    ...
    <Properties>
        <string>somethinghere</string>
        <string>somethinghere</string>
    </Properties>
    ...
</MyClass>

and now my question. How can I change my class to achieve XML like this:

<MyClass>
    ...
    <Properties>
        <Property>somethinghere</Property>
        <Property>somethinghere</Property>
    </Properties>
    ...
</MyClass>

after serializing. Thanks for any help!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET