title: VB.NET Serealize structure that contains lists
body: <p>I'm searching a way to serialize a structure that contains different kind of object such as Strings, Integer and Collections.</p>
  
  <p>I have this data structure:</p>
  
  <pre><code>Dim database as New mainStruct
  
  &lt;Serializable()&gt; Structure mainStruct
      Public name As String
      Public address As String
      Public Shared bookings As IList(Of booking) = New List(Of booking)
  End Structure
  
  &lt;Serializable()&gt; Structure booking
      Public id As Integer
      Public category As String
      Public description As String
  End Structure
  </code></pre>
  
  <p>running the serializer:</p>
  
  <pre><code>    Dim fs As FileStream = New FileStream("x.bin", FileMode.OpenOrCreate)
      Dim serial As New XmlSerializer(GetType(mainStruct))
      serial.Serialize(fs, database)
      fs.Close()
  </code></pre>
  
  <p>the output only contains all non-collection variables such as:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
    &lt;mainStruct xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;name&gt;foo&lt;/name&gt;
    &lt;address&gt;bar&lt;/address&gt;
  &lt;/mainStruct&gt;
  </code></pre>
  
  <p>How i can serialize bookings Collection, without creating separate files using GetType(List(Of booking))?</p>
  
  <p>Thanks!</p>