define a dictionary in c# code example
Example 1: c sharp create dictionary
IDictionary<int, string> dict = new Dictionary<int, string>();
dict.Add(1,"One");
dict.Add(2,"Two");
dict.Add(3,"Three");
IDictionary<int, string> dict = new Dictionary<int, string>()
{
{1,"One"},
{2, "Two"},
{3,"Three"}
};
Example 2: c# dictionary first
dictionary.Keys.First();
Example 3: c# dictionaries
IDictionary<int, string> dict = new Dictionary<int, string>();
Dictionary<int, string> dict = new Dictionary<int, string>();
Example 4: c sharp add item to dictionary
dict.Add(1,"One");
Example 5: c# dictionary functions
Dictionary<int, Func<string, bool>>