HashSet<Guid> sets =newHashSet<Guid>();for(int i =0; i <10000000; i++){Guid guid = Guid.NewGuid();
sets.Add(guid);}
Console.WriteLine(sets.Count());
Dictionary
Dictionary<string,string> dic =newDictionary<string,string>();
dic.Add("ddd","ooo");
dic.Add("uuu","zzzz");
Console.WriteLine(dic.ContainsKey("ddd"));
Console.WriteLine(dic.ContainsValue("ooo"));foreach(string key in dic.Keys){
Console.WriteLine($"{key}:{dic[key]}");}
dic.Remove("ddd");foreach(KeyValuePair<string,string> kv in dic){
Console.WriteLine($"{kv.Key}{kv.Value}");}
统计单词出现次数
string sentence ="this is a book that is a desk";string[] arr = sentence.Split(' ');Dictionary<string,int> dic =newDictionary<string,int>();foreach(string word in arr){if(dic.ContainsKey(word)){int count = dic[word];
count++;
dic[word]= count;}else{
dic.Add(word,1);}}foreach(KeyValuePair<string,int> kv in dic){
Console.WriteLine($"{kv.Key}-----{kv.Value}");}