0
我建立一個使用WriteAllLines通用功能的程序:無效參數當使用字符串數組
private static void WriteAllLines(string file, string[] contents)
{
using (StreamWriter writer = new StreamWriter(file))
{
foreach (string line in contents)
{
writer.Write(line);
}
}
}
但問題是,當我使用它是這樣的:
string temp = Path.GetTempFileName();
string file = ReadAllText(inputFile);
WriteAllLines(temp, value);
我知道爲什麼會出現這個問題,這是因爲value
是一個字符串,我把它放在一個字符串數組(string[]
)的地方,但我怎麼能改變我的代碼來解決這個問題?謝謝。
這有什麼錯File.WriteAllLines? http://msdn.microsoft.com/en-us/library/system.io.file.writealllines.aspx – 2009-11-12 17:56:27
不,它是另一個通用函數。 ;) – 2009-11-12 17:58:06