using System.Collections.Generic;
public static void Main()
var d = new Dictionary<string, object>( );
d.TryGetValue("b", out object nullObject);
Console.WriteLine((long)nullObject);
ExtractValue(d, "b", out long defaultLong);
Console.WriteLine(defaultLong);
protected static bool ExtractValue<T>(Dictionary<string, object> dict, string dimName, out T result)
if (!ExtractValue(dict, dimName, out T? preResult) || !preResult.HasValue)
result = preResult.Value;
protected static bool ExtractValue<T>(Dictionary<string, object> dict, string dimName, out T? result)
if (dict == null || !dict.TryGetValue(dimName, out object val))