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