gpt4 book ai didi

c# - 字典 : Will calling . 键的顺序是否与 .Values 一致?

转载 作者:太空宇宙 更新时间:2023-11-03 17:17:01 25 4
gpt4 key购买 nike

假设我有一个字典,并调用 .Keys,然后调用 .Values,没有中间操作。键的顺序是否与值的顺序一致?

换句话说,第n个键是否对应于第n个值,就像他们之前在字典中所做的那样?

最佳答案

Will the ordering of the keys be consistent with the ordering of the values?

是的, IDictionary<,>.Keys 的文档都保证了这一点和 IDictionary<,>.Values .

Keys文档:

The order of the keys in the Dictionary<TKey, TValue>.KeyCollection is unspecified, but it is the same order as the associated values in the Dictionary<TKey, TValue>.ValueCollection returned by the Values property.

Values文档:

The order of the values in the Dictionary<TKey, TValue>.ValueCollection is unspecified, but it is the same order as the associated keys in the Dictionary<TKey, TValue>.KeyCollection returned by the Keys property.

关于c# - 字典 : Will calling . 键的顺序是否与 .Values 一致?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31925538/

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