Dictionary instanciation 1

Dictionary instanciation

var x = new Dictionary {
   {"year", 2019}, {"month", 12}
};

Here is what the above code is Doing:
1. We’re creating a new Dictionary object.
2. We’re adding two key-value pairs to the dictionary.
3. We’re using the new object initializer syntax to do this.

The new object initializer syntax is a lot more concise than the old syntax.

Similar Posts