LINQ Select into Dictionary

Well, for starters, you’ll need your result to also include the key:

var tasks = clients.Select(async c => new
{
    c.Key,
    Value = await c.Value.ReceiveAsync(),
});

Then when the tasks finish you can put them in a dictionary:

var results = await Task.WhenAll(tasks);
var dictionary = results.ToDictionary(
    pair => pair.Key, pair => pair.Value); 

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)