c#Linq输出 [英] c# Linq Output
问题描述
这个linq如下正在返回完整的键值对 [关键,对象]。有人可以帮我使用linq来返回键值:
推荐答案
如果它正在这样做那么你就有了一个列表字典。对dict [dictItem.Key]的调用将返回存储在给定键中的值。既然您可以使用Skip进行编译,那么它就是一个列表列表。如果你得到一个KeyValuePair然后
你必须有一个词典字典。你能发布dict的类型声明吗?我怀疑你只需要在Take调用后调用Select(x => x.Value)来检索最终值。
If it is doing that then you have a dictionary of lists. The call to dict[dictItem.Key] would return back the value stored at the given key. Since you are then able to compile using Skip then it is a list of lists. If you're getting a KeyValuePair back then you must have a dictionary of dictionaries. Can you post the type declaration for dict? I suspect you just need to retrieve the final value by calling Select(x => x.Value) after the Take call.
还应该指出使用Skip / Take on a dictionary因为字典不能保证任何排序,所以行为不会表现得正确。
Should also point out that using Skip/Take on a dictionary isn't going to behave correctly potentially because a dictionary doesn't guarantee any ordering.
这篇关于c#Linq输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!