ConcurrentDictionarydict = new ConcurrentDictionary ();
dict.TryAdd(1, "one"); dict.TryAdd(2, "two"); dict.TryAdd(3, "three");
string value = null; if(dict.TryGetValue(2, out value)) { Console.WriteLine("Value is {0}", value); }
string removed = null; bool success = dict.TryRemove(2, out removed);
IEnumerableThe ConcurrentDictionary class is part of the System.Collections.Concurrent namespace, which is included in the System.Collections.Concurrent package/library.keys = dict.Keys; IEnumerable values = dict.Values;