Answers for "key value dictionary c#"

C#
7

dictionary c#

// Create a dictionary with 2 string values
Dictionary<string, string> capitalOf = new Dictionary<string, string>();

// Add items to the dictionary
capitalOf.Add("Japan", "Tokio");
capitalOf.Add("Portugal", "Lissabon");

// Loop over the dictionary and output the results to the console
foreach (KeyValuePair<string, string> combi in capitalOf)
{
  Console.WriteLine("The capital of " + combi.Key + " is " + combi.Value);
}
Posted by: Guest on October-30-2021
0

dictionary c#

var cities = new Dictionary<string, string>(){
	{"UK", "London, Manchester, Birmingham"},
	{"USA", "Chicago, New York, Washington"},
	{"India", "Mumbai, New Delhi, Pune"}
};
Posted by: Guest on March-03-2021
0

c# dictionary with dictionary as value

var collection = new Dictionary<string, Dictionary<string, int>>();
collection.Add("some key", new Dictionary<string, int>());
collection["some key"].Add("inner key", 0);
Posted by: Guest on October-19-2021

Code answers related to "key value dictionary c#"

C# Answers by Framework

Browse Popular Code Answers by Language