下面是我獲取的的一個Dictionary物件
public Dictionary<int, dynamic> GetCatalogTree() {
Dictionary<int, dynamic> dic = new Dictionary<int, dynamic>();
foreach (CatalogEntity catalog in CatalogViewModel.GetCatalogs()) { dynamic d = new ExpandoObject();
d.title = catalog.Title;
List<KeyValuePair<int,string>> list=new List<KeyValuePair<int,string>>();
this.CatalogId=catalog.CatalogId;
foreach (Catalog subCatalog in GetSubCatalogList()) {
KeyValuePair<int, string> kvp = new KeyValuePair<int, string(subCatalog.CatalogId,subCatalog.Title);
list.Add(kvp); }
d.list = list;
dic.Add(catalog.CatalogId, d);
}
return dic;}這裡面的字典K是一個int型別,V是一個動態型別dynamic,dynamic裡面的屬性有一個string title和一個List集合,list集合裡面存的是一個KVP的資料型別
下面是我獲取的的一個Dictionary物件
public Dictionary<int, dynamic> GetCatalogTree() {
Dictionary<int, dynamic> dic = new Dictionary<int, dynamic>();
foreach (CatalogEntity catalog in CatalogViewModel.GetCatalogs()) { dynamic d = new ExpandoObject();
d.title = catalog.Title;
List<KeyValuePair<int,string>> list=new List<KeyValuePair<int,string>>();
this.CatalogId=catalog.CatalogId;
foreach (Catalog subCatalog in GetSubCatalogList()) {
KeyValuePair<int, string> kvp = new KeyValuePair<int, string(subCatalog.CatalogId,subCatalog.Title);
list.Add(kvp); }
d.list = list;
dic.Add(catalog.CatalogId, d);
}
return dic;}這裡面的字典K是一個int型別,V是一個動態型別dynamic,dynamic裡面的屬性有一個string title和一個List集合,list集合裡面存的是一個KVP的資料型別