No, you cannot do this because the array always has a fixed size. If you do not specify this size for starters, what size do you expect to use? You either need to specify the size itself, or the content (which allows you to determine the size). For example:
int[] x = new int[10]; // Explicit size int[] y = new int[] { 1, 2, 3, 4, 5 }; // Implicit size int[] z = { 1, 2, 3, 4, 5 }; // Implicit size and type
List<T> definitely your friend for collections where you donβt know the size to start with.
Jon skeet
source share