An array in C # has a fixed size, so you must declare an array of 8 integers
int[] array = new int[8];
You only need to check the length
if(array.Length > 2) { Debug.WriteLine( array[2] ); }
This is great for value types, but if you have an array of reference types like
Person[] array = new Person[8];
then you will need to check for null, as in
if(array.Length > 2 && array[2] != null) { Debug.WriteLine( array[2].ToString() ); }
source share