jjzjj

c# - 在 select 语句中使用命名元组

有没有更好的方法使用var目标变量在C#7中选择命名元组?我一定在示例1中做错了什么,或者完全误解了某些东西。我似乎必须明确设置目标类型才能执行此操作。//1.Failstocompilewith"incorrectnumberoftypeparameters"issue.vartuples=source.Select(x=>(x.A,x.B));//2.CompilesIEnumerabletuples=toCheck.Select(x=>(x.A,x.B));//3.Compilesvartuples=newHashSet(source.Select(x=>(x.A,x.B)));