Declaring





Initializing

Added in .NET 4.6
There is now another way which is a more readable format

public Dictionary <string, string> MyDictionary = new Dictionary<string, string>() 
{
   {"Russell", "London"}
   {"Steven","New York"}
}

instead of

public Dictionary <string, string> MyDictionary = new Dictionary<string, string>() 
{
   ["Russell"] = "London"
   ["Steven"] = "New York"
}

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext