相关疑难解决方法(0)

Linq ToDictionary未定义?

我有这个代码

var contacts = dr.mktDoctorContacts
    .GroupBy(x => x.ContactType)
    .Select(zb => new 
     { 
         Key = zb.Key,
         GroupWiseContacts = zb.Select(x => x.Contact).ToList()
     })
    .ToDictionary<string,List<string>>(y => y.Key, y => y.GroupWiseContacts)
Run Code Online (Sandbox Code Playgroud)

我不知道这段代码有什么问题.

编译时错误msg说:System.Generic.IEnumerable不包含定义和最佳扩展方法重载有一些无效的参数.我在Visual Studio工具提示文档中只能看到ToDictionary方法的两个重载,而我在Web上遇到了两个以上的ToDictionary重载
编辑这里是编译时的确切错误消息

错误13' System.Collections.Generic.IEnumerable<AnonymousType#1>'不包含' '的定义,ToDictionary并且最佳扩展方法重载' System.Linq.Enumerable.ToDictionary<TSource,TKey>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,TKey>, System.Collections.Generic.IEqualityComparer<TKey>)'具有一些无效参数

linq linq-to-sql

9
推荐指数
1
解决办法
5223
查看次数

标签 统计

linq ×1

linq-to-sql ×1