通過集合類的CopyTo 方法將其轉化成DictionaryEntry 數組,再進行傳遞;客戶端接收後,再將其轉化成SortedList, ListDictionary 和 Hashtable 集合。
[WebMethod]
public DictionaryEntry[] HelloWorld()
{
SortedList sl = new SortedList();
sl.Add("Key","Value");
DictionaryEntry[] array = new DictionaryEntry[sl.Count];
sl.CopyTo(array, 0);
return array;
}
public void get(DictionaryEntry[] entrIEs)
{
SortedList list = new SortedList();
foreach (DictionaryEntry entry in entrIEs)
{
ist.Add(entry.Key, entry.Value);
}
}