Easy question about array

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

As I have understood this it means the following. Correct me if I'm wrong.
You store type objects in the array obj and the first one is refering to
a and the second is refering to b and the third is refering to c.
You store reference types of type object in the array but all of them is
refering to value types(a,b,c)

int32 a = 0;
Byte b = 0;
int16 c = 0;
object[] obj = {a,b,c};

It's the same as saying
object o1 = a;
object o2 = b;
object o3 = c;

//Tony
 
Hello!

As I have understood this it means the following. Correct me if I'm wrong..
You store type objects in the array obj and the first one is refering to
a and the second is refering to b and the third is refering to c.
You store reference types of type object in the array but all of them is
refering to value types(a,b,c)

int32  a = 0;
Byte  b = 0;
int16  c = 0;
object[] obj = {a,b,c};

It's the same as saying
object o1 = a;
object o2 = b;
object o3 = c;

//Tony

Array is a reference type, which holds a series of reference objects
or value type objects.

to know more http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx

-Cnu
 
Tony said:
Hello!

As I have understood this it means the following. Correct me if I'm wrong.
You store type objects in the array obj and the first one is refering to
a and the second is refering to b and the third is refering to c.
You store reference types of type object in the array but all of them is
refering to value types(a,b,c)

int32 a = 0;
Byte b = 0;
int16 c = 0;
object[] obj = {a,b,c};

It's the same as saying
object o1 = a;
object o2 = b;
object o3 = c;

//Tony

Yes, that is correct.

To store the values in the array, each value is boxed inside an object
that is allocated on the heap.
 
Back
Top