title: Add record to object of lists c#
body: <p>I have problem with adding a record to list, which is a parametr of object 'TranchesDt'.</p>
  
  <pre><code>public class TranchesDt
  {
      public List&lt;startup&gt; tranches {get; set;}
      public List&lt;reservation&gt; reservations { get; set; }
      public List&lt;location&gt; locations { get; set; }
  }
  </code></pre>
  
  <p>There is the code, where I add objects to 'TranchesDt':</p>
  
  <pre><code>public static TranchesDt Parse(string filePath)
  {
      string[] lines = File.ReadAllLines(filePath);
      TranchesDt dt = new TranchesDt();
  
      for (int i = 0; i &lt; lines.Length; i++)
      {
          string recordId = lines[i].Substring(0, 2);
  
          switch (recordId)
          {
              case "11":
                  {
                      dt.tranches.Add(Parse11(lines[i]));
                      break;
                  }
              case "01":
                  {
                      dt.locations.Add(Parse01(lines[i]));
                      break;
                  }
              case "00":
                  {
                      dt.reservations.Add(Parse00(lines[i]));
                      break;
                  }
          }
      }
      return dt;
  }
  
  public static startup Parse11(string line)
  {
      var ts = new startup();
      ts.code = line.Substring(2, 5);
      ts.invoice = line.Substring(7, 7);
      ts.amount = Decimal.Parse(line.Substring(14, 13));
      ts.model = line.Substring(63, 4);
      ts.brutto = Decimal.Parse(line.Substring(95, 13));
  
      return ts;
  }
  </code></pre>
  
  <p>And I get </p>
  
  <blockquote>
    <p>System.NullReferenceException: Object reference not set to an instance of an object.</p>
  </blockquote>
  
  <p>at the line  <em>dt.tranches.Add(Parse11(lines[i]));</em>
  Where my problem is and how can I fix it?</p>