title: How to create a list from a CSV file in c#?
body: <p>Simply put I have an excel CSV file with a table of Products and a Product Class in my project
  I can't seem to extract the data in order to create a list of Product objects from the list in the CSV file.
  I realise there is similar questions posted but I cannot seem to get it working correctly.
  Can anyone identify the problem ?</p>
  
  <pre><code>private static List&lt;Product&gt; ReadProductFile()
  {
      List&lt;Product&gt; products = new List&lt;Product&gt;();
      string curdir = Directory.GetCurrentDirectory();
      string filename = @"C:\Projects\ProductSales\ProductSales\Data\productdetails.csv";
  
      string[] linesInFile = File.ReadAllLines(filename);
      string[] ProductDetails = new string[0];
  
      for (int i = 0; i &lt; linesInFile.Length; i++)
      {
          string currentLine1 = linesInFile[i];
          ProductDetails = currentLine1.Split(',');
      }
  
      foreach (var p in ProductDetails)
      {
          Product prod = new Product()
          {
              prod.ID = p. ??
          };
          products.Add(prod);
      }
  }
  </code></pre>