Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 694
Aaron H Avatar asked Dec 19 '25 13:12

Aaron H


1 Answers

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

like image 191
DavidG Avatar answered Dec 22 '25 04:12

DavidG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!