title: Why I could not serialize a tuple in C#?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/267724/why-xml-serializable-class-need-a-parameterless-constructor">Why XML-Serializable class need a parameterless constructor</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to serialize a tuple in my code:</p>
  
  <pre><code>List&lt;List&lt;Tuple&lt;String, CodeExtractor.StatementNode&gt;&gt;&gt; results = null;
  results = extractor.ExtractSourceCode(sourceCode);
  FileStream fs = new FileStream(@"C:\Projects\Test\ast.xml", FileMode.Create);
  
  XmlSerializer formatter = new XmlSerializer(
      typeof(List&lt;List&lt;Tuple&lt;String, CodeExtractor.StatementNode&gt;&gt;&gt;));
  
  formatter.Serialize(fs, results);
  
  fs.Close();
  </code></pre>
  
  <p>but it was failed and catch the exception like this:</p>
  
  <blockquote>
    <p>System.Tuple`2[System.String,CodeExtractor.StatementNode] cannot be serialized because it does not have a parameterless constructor.</p>
  </blockquote>
  
  <p>and I'm do sure the <code>CodeExtractor.StatementNode</code> could be serialized.</p>