int b = 0;
int[] a = new int[b];
-
b
is
0
-
a
is initialized to be sized
0
- thus when you try to access it with an indext starting from 1, you are underindexing the empty array...
Btw: what's the use of this:
int[] a = arr;
? Nothing...
It is not clear what numArr would do, but you don't need to pass size, as the array is an object, which defines it's length. So if you want simply to list the elements, this would do it:
public static void numArray(int[] arr)
{
for (int i = 0; i < arr.Length; i++)
{
Console.WriteLine(arr[i]);
}
}