using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace APAR_csvTryout
{
class Program
{
static void Main(string[] args)
{
List<myclass> classInstance = new List<myclass>();
var lines = File.ReadLines(@"..\..\AcctSummaryInCSV.csv");
foreach (string line in lines)
{
var fields = line.Split(',');
var count = fields.Count();
string[] postions = new string[20];
for (int i = 0; i < count; i++)
{
postions[i] = fields[i];
}
for (int i = count; i < 20; i++)
{
postions[i] = "";
}
classInstance.Add(new MyClass()
{
Field0 = postions[0],
Field1 = postions[1],
Field2 = postions[2],
Field3 = postions[3],
Field4 = postions[4],
Field5 = postions[5],
Field6 = postions[6],
Field7 = postions[7],
Field8 = postions[8],
Field9 = postions[9],
Field10 = postions[10],
Field11 = postions[11],
Field12 = postions[12],
Field13 = postions[13],
Field14 = postions[14],
Field15 = postions[15],
Field16 = postions[16],
Field17 = postions[17],
Field18 = postions[18],
Field19 = postions[19]
});
}
}
}
public class MyClass
{
public string Field0 { get; set; }
public string Field1 { get; set; }
public string Field2 { get; set; }
public string Field3 { get; set; }
public string Field4 { get; set; }
public string Field5 { get; set; }
public string Field6 { get; set; }
public string Field7 { get; set; }
public string Field8 { get; set; }
public string Field9 { get; set; }
public string Field10 { get; set; }
public string Field11 { get; set; }
public string Field12 { get; set; }
public string Field13 { get; set; }
public string Field14 { get; set; }
public string Field15 { get; set; }
public string Field16 { get; set; }
public string Field17 { get; set; }
public string Field18 { get; set; }
public string Field19 { get; set; }
}
}</myclass></myclass>