Run Code
|
API
|
Code Wall
|
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
Armstrong
helloworld
Delegate, Method, List, Classes, Conditions
Консоль. Депозит
Program
sdfrgthyujyhtgrf
first
yarirey
Linq FirstOrDefault() null check in c#
congtodien