我正在使用csv reader
c#。这是我的Record
课
internal class Record
{
int _y;
int _x;
[Name("y")]
public int y { get; set; }
[Name("x")]
public int x { get; set; }
public int getSum()
{
return _x+_y;
}
}
然后,我尝试读取多个 .csv 文件并将聚合写入 1 个 .csv 文件
using (var writer = new StreamWriter(SaveTxt.Text))
using (var csvOut = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
for (int i = 0; i < Int16.Parse(numberFile); i++)
{
using (var reader = new StreamReader(files[i]))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
var records = csv.GetRecords<Record>();
csvOut.WriteRecords(records);
}
}
}
但结果只显示x
和y
数据。不显示getSum()
函数的结果。在写入其他 .csv 之前,我应该怎么做才能操作从 .csv 读取的数据?