【发布时间】:2020-02-22 11:44:42
【问题描述】:
我有一个包含以下数据的 CSV
month,year,speed
12,2010,76
2,2000,45
12,1940,30
我正在使用读取它的第 3 方加载。简而言之,它是一个 CSVReader 类,能够像这样从名为 input 的文件中获取数据
List<Dictionary<string, object>> data = CSVReader.Read("input");
然后,使用 for 循环,我能够以这种方式检索数据
for(var i=0; i < data.Count; i++) {
print ("month" + data[i]["month"] + " " +
"year" + data[i]["year"] + " " +
"speed " + data[i]["speed"]);
}
除了在 for 循环内部,我想将每年和每月(一个接一个)传递给另一个函数,该函数将诸如双精度数(而不是对象)之类的参数作为参数,但我不知道如何
for(var i=0; i < data.Count; i++) {
// Get month and year
function(month, year);
}
【问题讨论】:
-
函数(data[i].month, data[i].year);