title: Using CSV Helper to write a single record from a class
body: <p>I am using the library CSV Helper found at <a href="https://joshclose.github.io/CsvHelper/" rel="nofollow noreferrer">https://joshclose.github.io/CsvHelper/</a> to try and write a function that will export a class for me. Here is my example class:</p>
  
  <pre><code> public class Z1000
  {
      public string ModelNumber { get; set; }
      public string SerialNumber { get; set; }
      private string InputVolts { get; set; }
      private string InputHz { get; set; }
      private string InputPhase { get; set; }
      private string InputAmps { get; set; }
      private string OutputVolts { get; set; }
      private string OutputHz { get; set; }
      private string OutputPhase { get; set; }
      private string OutputAmps { get; set; }
      private string Type { get; set; }
      private string WiringDiagram { get; set; }
      private string SCCR { get; set; }
      private string FLA { get; set; }
      private bool SuitableForUseAsServiceEquipment { get; set; } = false;
      private List&lt;string&gt; InstanceManuals { get; set; } = new List&lt;string&gt;();
      private List&lt;string&gt; Options { get; set; } = new List&lt;string&gt;();
      private List&lt;Fuse&gt; Fuses { get; set; } = new List&lt;Fuse&gt;();              
    }
  </code></pre>
  
  <p>This class has several functions as well, I excluded them as they are not important to the question. Here is the function I am trying to use to export a single record.</p>
  
  <pre><code>public void ExportToCsv&lt;T&gt;(T classToExport)
      {
          using (StreamWriter writer = new StreamWriter(@"C:\Data\Output.csv"))
          {
              var csv = new CsvWriter(writer);
              csv.WriteHeader(typeof(T));
              csv.WriteRecord(classToExport);
          }
      }
  </code></pre>
  
  <p>The code executes just fine but for some reason the csv file that gets exported is just empty. Am I missing some kind of step here? I have tried it several different ways and just can't seem to lock it down. I read the documentation for writing and their examples and none of it seems to work for me. Am I missing something entirely?</p>
  
  <p>EDIT:
  I put a break point and verified the public member data is being written.
  <a href="https://i.stack.imgur.com/lGjWR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lGjWR.png" alt="enter image description here"></a></p>