c# - 是否可以在 C# 中创建一个非固定大小的数组?

标签 c# arrays list fixed-size-types

像with一样创建数组时

string[] list = new string[5]; 

有一个名为 IsFixedSize 的变量.那么是否可以创建一个不固定大小的数组?我知道的唯一方法是使用 List<string> . 我很困惑,因为我认为数组是固定大小,所以为什么会有 list.IsFixedSize

最佳答案

不,所有数组的大小都是固定的。如果您阅读 docs不过在属性(property)上,它解释了原因:

Property Value

Type: System.Boolean

This property is always true for all arrays.

和:

Array implements the IsFixedSize property because it is required by the System.Collections.IList interface

关于c# - 是否可以在 C# 中创建一个非固定大小的数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50956830/

相关文章:

c# - 泛化一个类来处理多种类型

c# - 删除数组字符串的第一个索引

c# - 我怎样才能显示两个asp :Panel controls side by side?

c++ - 如何在初始化后更改数组元素

R:循环列表列表以检索包含命中的子列表的标题

c# - WebSocket permessage-deflate C#

c - 如何在c中声明一个指向: array of void pointers?的指针

php - 如何从 mysql_fetch_array() 获取正确的列数?

c# - 为什么将 c# 泛型 List 实现为仅追加数组?

list - Haskell:如何 append 到元组列表列表?