Search code examples
c#arrayslistfixed-size-types

Is it possible to create a non-fixed size array in C#?


When creating an array like with

string[] list = new string[5]; 

There is a variable named IsFixedSize. So is it possible to create an array that is not fixed size? The only way I know is by using List<string>. I am confused because I thought arrays are about being fixed size, so why is there a list.IsFixedSize?


Solution

  • No, all arrays are fixed in size. If you read the docs on the property though, it explains why:

    Property Value

    Type: System.Boolean

    This property is always true for all arrays.

    And:

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