Guest User

Untitled

a guest
Dec 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. ConcurrentDictionary<int, string> dict = new ConcurrentDictionary<int, string>();
  4. dict.TryAdd(1, "January"); //returns true
  5. dict.TryAdd(2, "February"); //returns true
  6. dict.TryAdd(3, "March"); //returns true
  7. dict.TryAdd(4, "April"); //returns true
  8.  
  9. string removedItem;
  10. bool result = dict.TryRemove(4, out removedItem); //Returns true
  11. Console.WriteLine(removedItem); //Returns "April"
  12. }
Add Comment
Please, Sign In to add comment