c# - Problem Serializing a Class Containing a Collection using XML Serialization -


I have this XML snippet as part of an XML file that will be deserialized for the AC # object.

>
  & lt; EmailConfiguration & gt; & Lt; SendTo & gt; & Lt; Address & gt; MyEmailAdress@bah.com< / Address & gt; & Lt; Address & gt; Too & lt; / Address & gt; & Lt; / SendTo & gt; & Lt; Cc & gt; & Lt; Address & gt; CC & lt; / Address & gt; & Lt; / Cc & gt; & Lt; BCC & gt; & Lt; Address & gt; BCC & lt; / Address & gt; & Lt; / BCC & gt; & Lt; / EmailConfiguration & gt;  

Note that SendToAddress is a collection of addresses

  & lt; Address & gt; MyEmailAddress@bah.com< / Address & gt; & Lt; Address & gt; Too & lt; / Address & gt;  

My class currently looks like this

  public class SendTo {public string address {get; Set; }}  

This is good for 1 address, how do I change the class, so that it can handle more than 1 address.

I tried

Public class SendTo {public string [] address {get; Set; }}

But with it, nothing becomes when XML is deserialized for a class.

Update

tried ... without success ....

  Public class SendTo {public List & lt; String & gt; Address {receive; Set; }}  

This is the whole class

  namespace My Configuration {Public class myconfiguration {Private string myID; Public string myID {myID; } Set {myID = value; }} Public locale {get} Set; } Receive Public Email Configuration Email Configuration { Set; }} Public square locale {public string locale {get; Set; } Public string localecode {get; Set; }} Public class email configuration {public SendTo SendTo {set; get; } Public SendTo CC {Set; get; } Public SendTo BCC {Set; get; }} Public class SendTo {public list & lt; String & gt; Address {receive; Set; }}  

}

Here is the XML that I am deserializing ...

   

Try it out:

  [XmlArrayItem (" Address ", IsNullable = false]] public string [] SendTo {get this.sendToField; } Set {this.sendToField = value; }}  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -