If I have a class like this:
[Serializable]
public class Test
{
public int Foo {get; set;}
public object Bar {get; set;}
}
Then what is the cleanest way to do this:
Test example = new Test();
example.Foo = 123;
example.Bar = SomehowMakeThisInToAnObject("<this><is>Xml</is></this>");
var xs = new XmlSerializer(typeof(Test));
string xmlText = xs.Serialize(example);
(Sorry if there are syntax errors the code was just typed by hand)
I won't know what type the XML is going to have at design time but I will never need to access the Example property programatically - I just need it to appear in xmlText.
Thanks,
Joe
No comments:
Post a Comment