XML Serialization of empty collections does not self-close

I wonder if anyone can help me with this annoying but trivial (in terms of need) question. I have an object inside which is a collection of objects

 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 that I am 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 wonder why, when I don't have inner classes, it highlights

<OuterClass>
 <Name>Name</Name>
 <InnerClasses ></InnerClasses>
</OuterClass>

why doesn't it put InnerClasses as a private tag?

I understand that the code above will be placed, but I cannot put the full actual list of codes. (I don’t know how much good) I’m just looking for pointers as to what might cause this.

I cannot understand for life why this does not do this by default.

Thanks so much for any input regarding where to look.

+1
1

, , Serialization. . , .

+1

All Articles