c# - 列表、排序列表和数组列表之间有什么区别? (C#)

标签 c# arrays list sorting sortedlist

据我所知,列表、排序列表和数组列表有很多共同点,但同时也有一些不同之处。

我想知道:初学者应该知道的它们之间的区别是什么?为什么选择一个而不是另一个?在代码中使用它们时要养成哪些好习惯?

感谢您的宝贵时间。

最佳答案

来自 MSDN:

A SortedList element can be accessed by its key, like an element in any IDictionary implementation, or by its index, like an element in any IList implementation.

A SortedList object internally maintains two arrays to store the elements of the list; that is, one array for the keys and another array for the associated values. Each element is a key/value pair that can be accessed as a DictionaryEntry object. A key cannot be null, but a value can be.

还有选择最好的收藏你可以看到this .

enter image description here

关于c# - 列表、排序列表和数组列表之间有什么区别? (C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33406640/

相关文章:

python - 如何在字典列表中进行键值比较?

c# - LINQ to SQL DataContext.Translate 和名称与源名称不同的属性

c# - 获取保存的文件路径,无需任何回发

c# - 我将数组向左旋转 N 次的逻辑缺陷在哪里?

javascript - 如何像开发者控制台一样计算数组中的项目数

java - 将数组列表中的单个值存储到数组中

python - 在 python 中连接列表和元组的行为不一致

c# - 启动 MvvmCross Uwp 应用程序时出现异常 : "System.AccessViolationException: Attempted to read or write protected memory"

javascript - 创建一个函数以将整数数组旋转给定的步数

java.lang.ClassCastException : java. math.BigDecimal 无法转换为 java.lang.String