C# array accessiblity -
is there way prevent reinitialization of array? (to force specific length)
example initial:
int[] array = new int[3]{0,0,0};
usage:
array = new int[5]{1,2,3,4,5};
the above usage reinitialize array length of 5.
the array have 3 elements, values of elements changing.
i trying avoid doing following assign it's values:
array[0] = 1; array[1] = 2; array[2] = 3;
try declaring readonly
:
readonly int[] array = new int[3]{0,0,0};
Comments
Post a Comment