Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
}
 
PREVIOUS NEXT
Tagged: #dictionary
ADD COMMENT
Topic
Name
2+9 =