Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ConcurrentDictionary<T>
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 // //======================================================= // Code Examples from Exam Ref 70-483 //======================================================= // //AUTHOR: Wouter de Kort // //SECTION: Objective 1.1 - Chapter 1 // //MODIFICATION HISTORY //DATE NAME DESCRIPTION //----------- ---------------- -------------------- //10/19/2017 Cristian Canedo Initial commit //======================================================= using System; using System.Collections.Concurrent; namespace Rextester { public class Program { public static void Main(string[] args) { var dict = new ConcurrentDictionary<string, int>(); if (dict.TryAdd("k1", 42)) { Console.WriteLine("Added"); } if (dict.TryUpdate("k1", 21, 42)) { Console.WriteLine("42 updated to 21"); } dict["k1"] = 42; //overwriting unconditionally dict.AddOrUpdate("k1", 3, (s, i) => i * 2); dict.GetOrAdd("k2", 3); int result; if (dict.TryGetValue("k2", out result)) Console.WriteLine(result); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Why do my posts keep getting deleted?
Nuzrath 284
Selection sort
Plt-D v.0.9.2
Test
1
expression evaluator wich is easy to extend
Hex character codes
List of Lists example
UTC to Ireland time convertion v1.1
Please log in to post a comment.