Dynamic array

  • Thread starter Thread starter rozrabiak
  • Start date Start date
R

rozrabiak

Hello.
I need to create dynamic array, like: "int[,] myArray = new int[,]" and
"int[] myArray2 = new int[]"
How can I do this? In Delphi it's very simple, but I don't know how can
I do this in C#.

Can anyone help mi with this?
greetings, gregory.
 
Hello.
I need to create dynamic array, like: "int[,] myArray = new int[,]" and
"int[] myArray2 = new int[]"

int [] myArray = new int [10];

This declares a 10-element array of integers.
If you later need to change the size, you can simply write

myArray = new int [20];

You then have a 20-element array of integers. The garbage collection
routines take care of releasing the memory used by the original
10-element array.
 
Back
Top