METHOD
Dictionary<TKey,TValue>.TryGetValue
Returns whether a key was found and outputs the associated value or the default value when absent.
Formal Syntax & Structure
csharp syntaxcsharp
bool TryGetValue(TKey key, out TValue value)Working Example
Example Snippetcsharp
var map = new System.Collections.Generic.Dictionary<int, string> { [1] = "box" };System.Console.WriteLine(map.TryGetValue(1, out var item));