Answers for "find a key in a dictionary c#"

C#
0

get key in dictionary c#

public static string GetKeyFromValue(string valueVar)
{
   foreach (string keyVar in dictionaryVar.Keys) 
   { 
      if (dictionaryVar[keyVar] == valueVar)
      {
         return keyVar;
      }
   }
   return null;
}
Posted by: Guest on November-05-2021
0

c# find in dictionary

if (_tags.TryGetValue(tag, out string myValue))
{
    // use myValue;
}
// use myValue, still in scope, null if not found
Posted by: Guest on July-21-2021

Code answers related to "find a key in a dictionary c#"

C# Answers by Framework

Browse Popular Code Answers by Language