Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个返回IEnumerable以下类的函数
IEnumerable
public class User { public string UserName { get; set; } public IList<string> MemberOf { get; set; } }
我如何将 IEnumerable 转换为 LookUp ,键是用户名,值是 memberOf 列表
IEnumerable<User> seq = ...; ILookup<string, IList<string>> lookup = seq.ToLookup(u => u.UserName, u => u.MemberOf);