1
我正在寻找一些帮助,使用WebService中的csv文件填充字典,但是我无法返回结果。使用webservice返回字典
为了将字典分成两个看似有效的单独列,但由于有两个而不是一个,所以我不能返回值。
这里是代码:
{
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>"
任何想法将是巨大的,感谢您的时间
非常感谢,这是非常有益的和解决。虽然如你所说不正确,因为Web服务不接受字典类。我会看看序列化的XML字典,并从那里开始。再次感谢你。 – user3034104