I have this xml snippet as part of a xml file that will be deserialized to a c# object
<EmailConfiguration>
<SendTo>
<Address>[email protected]</Address>
<Address>also send to</Address>
</SendTo>
<CC>
<Address>CC</Address>
</CC>
<BCC>
<Address>BCC</Address>
</BCC>
</EmailConfiguration>
Notice the SendToAddress is a collection of Addresses
<Address>[email protected]</Address>
<Address>also send to</Address>
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 this, nothing gets populated when the xml is deserialized to a class.
Update
tried...also without success....
public class SendTo
{
public List<string> Address
{
get;
set;
}
}
Here is the entire class
namespace myConfiguration
{
public class myConfiguration
{
private string myID;
public string MyID
{
get { return myID; }
set { myID = value; }
}
public Locale Locale
{
get;
set;
}
public EmailConfiguration EmailConfiguration
{
get;
set;
}
}
public class Locale
{
public string LocaleName
{
get;
set;
}
public string LocaleCode
{
get;
set;
}
}
public class EmailConfiguration
{
public SendTo SendTo
{
set;
get;
}
public SendTo CC
{
set;
get;
}
public SendTo BCC
{
set;
get;
}
}
public class SendTo
{
public List<string> Address
{
get;
set;
}
}
}
Here is the XML that I am deserializing from ...
<?xml version="1.0" encoding="utf-8" ?>
<MyConfiguration>
<MyID>vpfaewb</MyID>
<Locale>
<LocaleName>cs-CZ</LocaleName>
<LocaleCode>1029</LocaleCode>
</Locale>
<EmailConfiguration>
<SendTo>
<Address>my email address</Address>
<Address>also send to</Address>
</SendTo>
<CC>
<Address>CC</Address>
</CC>
<BCC>
<Address>BCC</Address>
</BCC>
</EmailConfiguration>
</MyConfiguration>