【发布时间】:2011-12-30 19:03:45
【问题描述】:
如果标题不够准确,请随时将其更改为更恰当的名称。
所以我有一个公共静态无效:
public static void outputDictionaryContents(Dictionary<string, int> list)
{
foreach (KeyValuePair<string, int> pair in list)
{
Console.WriteLine("{0}, {1}", pair.Key, pair.Value);
}
}
我想写出它在 html 文件中产生的内容,它将通过以下方式在命令提示符下正常输出:
outputDictionaryContents(sortedDict);
但是当涉及到使用以下代码在我的 html 中输出它时:
tw.WriteLine("<td width\"480\">{0}</td>", outputDictionaryContents(sortedDict));
但我不断收到以下错误:
The best overloaded method match for 'System.IO.TextWriter.WriteLine(string, object)' has some invalid arguments
Argument '#2' cannon convert 'void' expression to type 'object'
所以我不完全确定解决这个问题的最佳方法是什么。
提前致谢。
【问题讨论】:
-
你到底想写什么?您的方法将输出发送到控制台,您打算将什么放入
<td>单元格?