我是 C# 的初学者。我有一本这样的字典:
{
{"tom", "student"},
{"rob", "teacher"},
{"david", "lawyer"}
}
我想形成这条线:
tom = student, rob = teacher, david = lawyer
我想使用聚合扩展方法,dictionary<>
但是当我这样做时:
Console.WriteLine(dic.Aggregate((a,b) => (a.Key + " = " + a.Value + ", " + b.Key + " = " + b.Value)));
我收到此错误:
无法将 lambda 表达式转换为委托类型。
所以看来我做错了。那么有人可以告诉我如何使用这种方法吗?