How do i declare a new lookup class for a property in the object initializer routine in c#?
E.g.
new Component() { ID = 1, Name = \"MOBO\", Category
If you just need to return an empty ILookup
for some reason you can return one from an empty dictionary. For example, to make an ILookup
, you can use this:
return new Dictionary().ToLookup(kvp => kvp.Key, kvp => kvp.Value);
Unfortunately this is the most concise way I can see to do it without having to make a class that implements ILookup
yourself.