get values of dictionary C# code example

Example 1: c# dictionary get value by key

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

Example 2: find the values of dictionaries in C sharp

//sets the dictionary item, "dictionary item" to 20
dictionary["dictionary item"] = 20;

Example 3: c sharp add item to dictionary

// To add an item to a dictionary use 'Add()'
dict.Add(1,"One");