请问HashSet的preserve插入顺序? [英] Does HashSet preserve insertion order?

查看:196
本文介绍了请问HashSet的preserve插入顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问的HashSet 收集介绍了.NET 3.5 preserve插入顺序在使用迭代的foreach

Does the HashSet collection introduced in .NET 3.5 preserve insertion order when iterated using foreach?

借助文档状态,该集合没有排序,但它没有说有关插入顺序什么。一个pre释放BCL 博客条目指出,它是无序的,但这篇文章说,它被设计为preserve插入顺序。我有限的测试表明,该订单是preserved,但可能是一种巧合。

The documentation states, that the collection is not sorted, but it doesn't say anything about insertion order. A pre-release BCL blog entry states that it is unordered, but this article states that it is designed to preserve insertion order. My limited testing suggests, that order is preserved, but that could be a coincidence.

推荐答案

此HashSet的MSDN页面特别说:

一组是不包含重复元素,并且它的元素是没有特定的顺序集合。

A set is a collection that contains no duplicate elements, and whose elements are in no particular order.

这篇关于请问HashSet的preserve插入顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆