Easy question about array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Johansson

    Easy question about array

    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

  • Duggi

    #2
    Re: Easy question about array

    On 22 Sep, 17:44, "Tony Johansson" <t.johans...@lo gica.comwrote:
    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/libr...53(VS.71).aspx

    -Cnu

    Comment

    • =?ISO-8859-1?Q?G=F6ran_Andersson?=

      #3
      Re: Easy question about array

      Tony Johansson wrote:
      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.

      --
      Göran Andersson
      _____
      Göran Anderssons privata hemsida.

      Comment

      Working...