I was working with my project in Visual studio in c#, but one thing I don't know about is that when we reallocate a array (no matter what type it is of) then does the previous values that stored in the array are destroyed or they are not? For Example:
int[] a=new int[2];
a[0]=200;
a[1]=400;
Now I reallocated the array 'a' with 4 elements:
a=new int[4];
Now, does the previous values will be there or they changed to something new value, i mean garbage, zero or they will be as they was? I also tried it myself in visual studio, and value didn't changed, but I want to be sure if really they don't.
Array.Resize(ref a, 4);whena = new int[4];creates a new array with all items equals todefault(int),0in your case