collection-initializer

What benefits does dictionary initializers add over collection initializers?

强颜欢笑 提交于 2019-11-27 23:24:41
In a recent past there has been a lot of talk about whats new in C# 6.0 One of the most talked about feature is using Dictionary initializers in C# 6.0 But wait we have been using collection initializers to initialize the collections and can very well initialize a Dictionary also in .NET 4.0 and .NET 4.5 (Don't know about old version) like Dictionary<int, string> myDict = new Dictionary<int, string>() { { 1,"Pankaj"}, { 2,"Pankaj"}, { 3,"Pankaj"} }; So what is there new in C# 6.0, What Dictionary Initializer they are talking about in C# 6.0 While you could initialize a dictionary with

What benefits does dictionary initializers add over collection initializers?

末鹿安然 提交于 2019-11-27 04:40:28
问题 In a recent past there has been a lot of talk about whats new in C# 6.0 One of the most talked about feature is using Dictionary initializers in C# 6.0 But wait we have been using collection initializers to initialize the collections and can very well initialize a Dictionary also in .NET 4.0 and .NET 4.5 (Don't know about old version) like Dictionary<int, string> myDict = new Dictionary<int, string>() { { 1,"Pankaj"}, { 2,"Pankaj"}, { 3,"Pankaj"} }; So what is there new in C# 6.0, What