像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 theSystem.Collections.IList
interface
关于c# - 是否可以在 C# 中创建一个非固定大小的数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50956830/