How to read lines to dictionary with linQ [closed]

The problem is that you need to provide a lambda expression for the second argument of ToDictionary. ToDictionary also returns a Dictionary<T, U> so you won’t be able to assign it to an instance of ConcurrentDictionary<T, U>.

This should do the trick:

var dicFailedProxies = 
        .ToDictionary(line => line, line => 0);

Of course, if you want to keep it as a ConcurrentDictionary<T, U> you can do this:

var dicFailedProxies = new ConcurrentDictionary<string, int>(
        .ToDictionary(line => line, line => 0));

Browse More Popular Posts

Leave a Comment