Loading…
december code / try / csharp
No account needed. Answer, see why, move on.
Problem
What happens when this C# code runs?
var d = new Dictionary<string, int>(); d["a"] = 1; d["a"] = 2; Console.WriteLine($"{d.Count} {d["a"]}"); Console.WriteLine(d["b"]);
It prints 2 2, then 0
It prints 1 2, then throws a KeyNotFoundException
It prints 1 2, then 0
It throws an ArgumentException at the second assignment
Nothing here is saved. Create a free account to keep your progress, take an assessment and get your readiness score.