C# ToDictionary can valueSelector give null?
Posted
by Trimack
on Stack Overflow
See other posts from Stack Overflow
or by Trimack
Published on 2010-05-02T09:44:08Z
Indexed on
2010/05/02
9:47 UTC
Read the original article
Hit count: 229
c#
Hi, I want to make a dictionary out of list in a way, that the list becomes keys and values would be empty. I have following code
Dictionary<XmlTest, int?> testBattery =
new XmlTests().GetRandomTestBattery(id).
ToDictionary(k => k, v => null);
But I am getting the error "Cannot convert lambda expression to type System.Collections.Generic.IEqualityComparer' because it is not a delegate type"
Any ideas how could I fix it?
(I know I could iterate through and fill the dict one element at a time, but I simply want to use something more elegant)
© Stack Overflow or respective owner