title: How can I XML serialize an array of object lists?
body: <p>I get these errors when I try to XML serialize an array of lists.</p>
  
  <blockquote>
    <p>Unable to generate a temporary class (result=1). error CS1026: )
    expected error CS1002: ; expected ... error CS1525: Invalid expression
    term ')' error CS1002: ; expected</p>
  </blockquote>
  
  <p>Here's my code:</p>
  
  <p>This is the method that triggers the exception.</p>
  
  <pre><code>public static string SerializeToString&lt;T&gt;(T obj)
  {
      XmlSerializer serializer = new XmlSerializer(typeof(T));
      using (StringWriter writer = new StringWriter())
      {
          serializer.Serialize(writer, obj);
          return writer.ToString();
      }
  }
  </code></pre>
  
  <p>And this is the var passed to it:</p>
  
  <pre><code>List&lt;Transaction&gt;[] allTransactions = new List&lt;Transaction&gt;[20];
  </code></pre>
  
  <p>Thanks for any help.</p>
  
  <p>[UPDATE]</p>
  
  <pre><code>public class TransactionCollection
  {
      public List&lt;Transaction&gt;[] transactions;
  
      public TransactionCollection()
      {
      }
  
      public void Set(List&lt;Transaction&gt;[] t)
      {
          transactions = t;
      }
  }
  </code></pre>