Wondering if anyone can help me with this annoying but trivial (in terms of need) question. I have an object which has inside it a collection of object
public class OuterClass
{
InnerClasses innerClasses= new InnerClasses();
public InnerClasses InnerClasses
{
get {return innerClasses; }
}
public string Name
{
get;set;
}
}
public class InnerClasses:List<InnerClass>
{
}
public class <InnerClass>
{
}
basically my problem I'm experiencing is that if I pass it through an xml serializer
var outer = new OuterClass(){Name="Name"}
var xmlSerializer = new XmlSerializer(GetType());
var stringBuilder = new StringBuilder();
var stringWriter = new StringWriter(stringBuilder);
xmlSerializer.Serialize(stringWriter, this);
return stringBuilder.ToString();
I'm wondering why when I have no inner classes it puts out
<OuterClass>
<Name>Name</Name>
<InnerClasses ></InnerClasses>
</OuterClass>
why does it not put InnerClasses as a self closed tag ?
I realize the code above will put but I can't put the full actual code listing. (not much use I know) I'm just looking for pointers as to what could cause it.
I can't for the life of me work out why it's not doing this by default.
Many thanks for any input as to where to look.