c# 将CSV文件转成list集合
//定义CSV文件所对应的实体类 public class example { public int t1; public string t2; public string t3; public static example FromCsv(string csvLine) { string[] values = csvLine.Split(','); example dailyValues = new example(); dailyValues.t1 = Convert.ToInt32(values[0]); dailyValues.t2 = values[1]; dailyValues.t3 = values[2]; return dailyValues; } } //将csv文件用linq转换为list集合 List<example> values = File.ReadAllLines("d:\\test.csv") .Skip(1) .Select(v => example.FromCsv(v)) .ToList(); foreach (var item in values) { listBox1.Items.Add(item.t1); }