Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Linq to objects, how to create an empty dictionary of <string, string> easily?

Tags:

c#

linq

To create an empty sequence one uses the following

var empty = Enumerable.Empty<string> (); 

Is there an equivalent for creating an empty dictionary as easily as this?

like image 753
Stécy Avatar asked May 03 '12 12:05

Stécy


1 Answers

Back to year 2019, there is a way to achieve this, using:

ImmutableDictionary<TKey, TValue>.Empty 

More info can be found here (last couple of posts): https://github.com/dotnet/corefx/issues/25023

like image 188
Mladen B. Avatar answered Sep 22 '22 22:09

Mladen B.