Thursday, September 29, 2016

C# 6.0 Dictionary Initializer

C# 7.0 is on the horizon but I’m still getting used to some of the new features of C# 6.0. One of the features I didn’t use until recently were dictionary initializers.

Before C# 6.0, you had to do something like this:

In C# 6.0, you could separate keys from values by using the indexer syntax making the code easier to read and understand:

No comments: