title: Is there a way to read list & headers separately from CSV file without using any library in C#?
body: <p>So I've got a program made with my mentor, it's all about creating CSV file with list of objects who are premade.
  But as I want to keep progressing, I want to make it more automatic.</p>
  <p>The question is: <strong>Can I make my program to read header of CSV file and append value to it while creating new list of objects without any non .NET library?</strong></p>
  <pre><code>static void Main(string[] args)
          {
  
              /*
              1. In new files create two classes: House (properties: Id - int, Surface - int, Name - string, IsFlat - bool, Description - string), Human (Id - int, BirthDate - DateTime, Height - byte)
              In Houses description use some commas and watch out for them as it is a common csv separator and may cause you some trouble.
              2. Create two lists with at least 5 elements each, one with Houses and one with Humans
              3. Create two csv files and append to them the right text (check in Excel if it works)
              4. Try to extract the data from the files - two new variables that will have exactly the same as the ones created manually in the second step
              */
  
              List&lt;House&gt; houses = new List&lt;House&gt;() {
                  new House(1, 100, &quot;Stanowski&quot;, true, &quot;House has two separate floors, upstairs there is a bedroom and a toilet, downstairs family has living room, kitchen and small garderobe&quot;),
                  new House(2, 240, &quot;Borek&quot;, false, &quot;This house has also two floors, small garden outside and inside there is 3 bedrooms, huge living room and nice - modern kitchen.&quot;),
                  new House(3, 140, &quot;Pol&quot;, true, &quot;This house has bald floors&quot;),
                  new House(4, 280, &quot;Boniek&quot;, false, &quot;This house is simply - TOP&quot;),
                  new House(5, 50, &quot;Lewandowski&quot;, true, &quot;This house has golden balls around the living room&quot;)
              };
              List&lt;Human&gt; humans = new List&lt;Human&gt;() {
                  new Human(1, new DateTime(1980, 7, 21), 185),
                  new Human(2, new DateTime(1986, 4, 7), 176),
                  new Human(3, new DateTime(2000, 8, 21), 200),
                  new Human(4, new DateTime(2004, 2, 20), 145),
                  new Human(5, new DateTime(1995, 11, 11), 198)
              };
              var strFilePath = @&quot;C:\Users\Szymon\source\repos\ProjektCSV\ProjektCSV\&quot;;
              var humanFileName = &quot;humans.csv&quot;;
              var houseFileName = &quot;houses.csv&quot;;
              // Take list of properties from an object. - ekspression 'nameof'
  
              var houseColumnNamesString = CsvTools.GetClassPropertiesString&lt;House&gt;();
  
              var humanColumnNamesString = CsvTools.GetClassPropertiesString&lt;Human&gt;();
  
              
              var humanValues = new StringBuilder(&quot;&quot;);
              foreach (var human in humans)
              {
                  humanValues.Append($&quot;{human.Id};{human.BirthDay};{human.Height};\n&quot;);
              }
  
              
              using (StreamWriter fileHuman = new StreamWriter(strFilePath + humanFileName, false))
              {
                  fileHuman.WriteLine(humanColumnNamesString);
                  fileHuman.WriteLine(humanValues);
              }
              // Separate to different methods/classes 
              
              
              var readCSV = CsvTools.ReadCsv(strFilePath + houseFileName);
              Console.WriteLine(readCSV);
              
              
              //TODO
              // Make automatic reading of properties and it's values, like instead of house.ID in line 72
              using (var reader = new StringReader(manyLines))
              {
                  string? item;
                  do {
                      item = reader.ReadLine();
                      Console.WriteLine(item);
                      } while(item != null);
              }
              var houseValues = new StringBuilder(&quot;&quot;);
              foreach (var house in houses)
              {
                  houseValues.Append($&quot;{house.Id};{house.Name};{house.Surface};{house.IsFlat};{house.Description};\n&quot;);
              }
              using (StreamWriter file = new StreamWriter(strFilePath+houseFileName, false)) // true = add | false = overwrite
              { 
                  file.WriteLine(houseColumnNamesString);
                  file.WriteLine(houseValues);
              }
          } 
  </code></pre>
  <p><strong>Okay, so is that what I needed?</strong></p>
  <pre><code>using(StreamReader file = new StreamReader(strFilePath + houseFileName))
              {
                  string line;
                  string headers = line.Take(1);
                  while((line = file.ReadLine()) != null )
                  {
                      var content = new List&lt;House&gt;(line);
                  }    
              }
  </code></pre>