Answers for "c# dictionary example code"

C#
10

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

C# Answers by Framework

Browse Popular Code Answers by Language