Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# dictionary initializer

var dictionary = new Dictionary<string, string>
{
     { "LAX", "Los Angeles International Airport" },
     { "MEL", "Melbourne Tullamarine Airport" }
};

//C# 6 introduces a new index-like syntax to initialize dictionaries: 
var dictionary = new Dictionary<string, string>
{
     ["LAX"] = "Los Angeles International Airport",
     ["MEL"] = "Melbourne Tullamarine Airport"
};
 
PREVIOUS NEXT
Tagged: #dictionary #initializer
ADD COMMENT
Topic
Name
8+2 =