Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# get key by value Dict

var myKey = myDict.FirstOrDefault(x => x.Value == "myValue").Key;
// return the first key finded in the dict associated to this value
Comment

c# dictionary get value by key

 Dictionary<string, string> dict = new Dictionary<string, string>();
 dict.Add("UserID", "test");
 string userIDFromDictionaryByKey = dict["UserID"];
Comment

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);
                }
            }
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to read values from appsettings.json in c# 
Csharp :: c# string array contains 
Csharp :: c# minus days from datetime 
Csharp :: c# file directory selection 
Csharp :: create list with values c# 
Csharp :: randomm number from 2 different ranges 
Csharp :: c# indexof 
Csharp :: top down movement unity 
Csharp :: c# itext 7 pdf add pdf 
Csharp :: run wpf application maximized 
Csharp :: c# loop string array 
Csharp :: read embedded resource c# xml 
Csharp :: good food 
Csharp :: change button color in script unity 
Csharp :: get description from enum c# 
Csharp :: total months between two dates c# 
Csharp :: unity event 
Csharp :: mapping dictionary to object c# 
Csharp :: add text to combobox c# 
Csharp :: how to store an array inside an array c# 
Csharp :: npm install --save vue-route@n 
Csharp :: c# find substring in string 
Csharp :: how to get text from textbox in windows form c# 
Csharp :: git find commits by file path 
Csharp :: weapon switching unity 
Csharp :: c# int array 
Csharp :: how to make a enter in C# string 
Csharp :: valid URL check in c# 
Csharp :: calculate how much memory an object take c# 
Csharp :: char to digit in java 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =