gpt4 book ai didi

c# - 如何在字典中找到最小键

转载 作者:太空狗 更新时间:2023-10-29 19:55:13 26 4
gpt4 key购买 nike

我声明字典如下:

private Dictionary<int, touchInformation> touchDictionary = new Dictionary<int, touchInformation>();

我使用如下:

touchDictionary[touchID] = touchObject;

因此,touchDictionary 会保留来自 touchID 的 key 。现在,我尝试使用字典查找最小键,但我不知道该怎么做。有什么建议吗?

注意,C.波拉瓦特

最佳答案

Dictionary 有一个 Keys 属性,它允许您枚举字典中的键。您可以使用 Min Linq 扩展方法来获取最小 key ,如下所示:

int minimumKey = touchDictionary.Keys.Min();

关于c# - 如何在字典中找到最小键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4802737/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com