Heinz Field
Heinz Field

Reputation: 25

Variable size Array in Java or C#

I'm trying to be able to alter the size of an array based on a variable. I was thinking I might maybe later make it a 2D array. I don't want to use arraylist.

int i = 4;
int[] arr = new int[i];

How do you get something like this to work? It gives me error CS0236.

Upvotes: 1

Views: 50

Answers (1)

Marcus
Marcus

Reputation: 116

You have to make the int static

Upvotes: 1

Related Questions