我有这种方法,并得到上述错误的行words.Add(rows);谁能帮忙?谢谢 - 奔C#无法从字符串[]转换为字符串
private static IEnumerable<string> LoadWords(String filePath)
{
List<String> words = new List<String>();
try
{
foreach (String line in File.ReadAllLines(filePath))
{
string[] rows = line.Split(',');
words.Add(rows);
}
}
catch (Exception e)
{
System.Windows.MessageBox.Show(e.Message);
}
return words;
}
列表为了你自己的信息,[这里](http://stackoverflow.com/questions/3891157/an-i-使用通用限制/ 3891439#3891439)Eric Lippert解释了为什么“添加”和“添加范围”是分开的功能。 [这里](http://stackoverflow.com/questions/3891157/an-i-prevent-a-specific-type-using-generic-restrictions/3891584#3891584)LBushkin进入更多的细节,看着技术限制,使这种选择必要。如果没有这些技术限制,拥有两个独立的功能仍然是一个好主意。 – Brian 2011-03-18 17:38:01