【发布时间】:2016-03-11 10:50:22
【问题描述】:
我有一个 CSV 文件,格式如下:名字、姓氏、出生日期、死亡日期。如何从我的 CSV 文件中获取所有数据并将它们转换为对象列表?
我正在考虑实现以下类
public class Person
{
private string f_name;
private string l_name;
private int dob;
private int dod;
public Person(string first, string second, int dob, int dod)
{
this.f_name = first;
this.l_name = second;
this.dob = dob;
this.dod = dod;
}
}
【问题讨论】:
-
很遗憾有这么多的CSV解析问题,其中大多数答案都依赖于简单的字符串拆分。 这是错误的。使用 CSV 解析库。