我正在向流编写器和字符串生成器发送几个字典,但只有一个字典的信息显示在我的输出文件中。我不知道该怎么做才能立即输出所有内容,代码如下,谢谢!
public void RunReport()
{
CSVProfileCreate(genderKeys, genderValues);
CSVProfileCreate(ageKeys, ageValues);
}
public void CSVProfileCreate<T>(Dictionary<T, string> columns, Dictionary<T, int> data)
{
using (StreamWriter write = new StreamWriter("c:/temp/testoutputprofile.csv"))
{
StringBuilder output = new StringBuilder();
IEnumerable<string> col = columns.Values.AsEnumerable();
IEnumerable<int> dat = data.Values.AsEnumerable();
for (int i = 0; i < col.Count(); i++)
{
output.Append(col.ElementAt(i));
output.Append(",");
output.Append(dat.ElementAt(i));
output.Append(",");
output.Append(Environment.NewLine);
}
write.Write(output);
}
}