try this:
var dict = result.ToDictionary(x => x.Key, x => x.Select(y => y.Key).ToList())
and access it like
foreach(var item in dict)
BTW, there's no type var
. It's just instruction for the compiler to determine type for variable, but it's strongly typed. In your case, I think, it would be IEnumerable<IGrouping<TKey, TSource>>
. Actually you can access result
like this too:
foreach(var item in result)
{
// item is type Lookup<int, KeyValuePair<string, int>>.Grouping
// you can go through item like
foreach(var i in item)
{
}
// or convert it ToList()
var l = item.ToList()
// l is type List<KeyValuePair<string, int>>
}