Try Value

MethodName() starting with Try - part

Get Value by Key

  • GetValueOrDefault

.net core

  • TryGetValue

fx

GetValueOrDefault

Dictionary<string, string> m_kbd = new Dictionary<string, string>();
result += m_kbd.GetValueOrDefault(kbd.Key);

TryGetValue

Dictionary<string, string> m_kbd = new Dictionary<string, string>();
result += m_kbd.TryGetValue(kbd.Key, out var value)? value : null;

Get an integer from a string

  • TryParse

TryParse

string itostr(string val)
{
    string result = "";
    int iVal = 0;

    if (Int32.TryParse(val, out iVal))
    {
        val = "_" + val;
    }

    result = val;

    return result;
}

Ref