Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# dictionary get key by value

            Dictionary<string, string> dict = new Dictionary<string, string>()
              {
                {"1", "one"},
                {"2", "two"},
                {"3", "three"}
              };
            foreach (var item in dict)
            {
                if(item.Value == "One")
                {
                    var firstElementKey = item.Key;
                  	Console.WriteLine(firstElementKey);
                }
            }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dictionary #key
ADD COMMENT
Topic
Name
9+7 =