【发布时间】:2013-11-25 21:44:18
【问题描述】:
我正在寻找一些关于使用 WebService 中的 csv 文件填充字典的帮助,但是我无法返回结果。
我试图将字典分成两个单独的列,这似乎可行,但我无法返回值,因为有两个而不是一个。
代码如下:
{
StreamReader streamReader = new StreamReader("T:/4 Year WBL/Applications Development/Coursework 2/2b/Coursework2bwebservice/abrev.csv");
[WebMethod]
public string Dictionary()
{
string line;
Dictionary<string, string> dictionary = new Dictionary<string,string>();
while ((line = streamReader.ReadLine()) !=null)
{
string[] columns = line.Split(',');
dictionary.Add(columns[0], columns[1]);
return dictionary;
}
}
我收到错误“无法隐式转换类型System.Collections.Generic.Dictionary<string,string to string>"
任何想法都会很棒,感谢您抽出宝贵时间。
【问题讨论】:
标签: dictionary c#-3.0 streamreader