📅  最后修改于: 2022-03-11 14:48:50.204000             🧑  作者: Mango
sealed class CSVFileDefinitionMap : CsvClassMap
{
public CSVFileDefinitionMap()
{
Map(m => m.FRM_ID).Name("FARM ID");
Map(m => m.FRM_OWNER).Name("FARM OWNER ");
}
}
class CSVFileDefinition
{
public string FRM_ID { get; set; }
public string FRM_OWNER { get; set; }
}
using (TextReader reader = File.OpenText(fileName)) {
var csv = new CsvReader(reader);
csv.Configuration.RegisterClassMap();
while (csv.Read()) {
var record = csv.GetRecord();
}
}