You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dictionary<string,string>dict=newDictionary<string,string>();dict.Add("scott","harden");dict.Add("bill","gates");dict.Add("steve","jobs");// print items in the order they were addedforeach(stringkeyindict.Keys)Console.WriteLine($"{key} = {dict[key]}\n");// print items in alphabetical orderList<string>keyList=newList<string>(dict.Keys);keyList.Sort();foreach(stringkeyinkeyList)Console.WriteLine($"{key} = {dict[key]}\n");
Dictionary where the value is a list
Dictionary<string,List<string>>abfIDsByParent=newDictionary<string,List<string>>();// add every ABF to its particular parentabfIDsByParent.Clear();stringcurrentParent="orphan";foreach(stringabfIDinabfIDs){// update our parent if neededif(abfParentIDs.Contains(abfID)){currentParent=abfID;}// ensure the key exists in the dictionaryif(!abfIDsByParent.ContainsKey(currentParent)){abfIDsByParent.Add(currentParent,newList<string>());}// add this ABF to the dictionary key listList<string>l=abfIDsByParent[currentParent];l.Add(abfID);abfIDsByParent[currentParent]=l;}