samedi 25 avril 2015

C# array accessiblity


Is there a way to prevent reinitialization of an 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 will reinitialize the array with length of 5.

The array will always have 3 elements, but the values of the elements will always be changing.

I am trying to avoid doing the following to assign it's values:

array[0] = 1;
array[1] = 2;
array[2] = 3;


Aucun commentaire:

Enregistrer un commentaire