Results 1 to 4 of 4

Thread: Reference types

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Reference types

    If i make a reference to a refence type then if i make another reference to the same object and change it, the inicial one will be changed as they point to the same object right? if i have 2 or more hashtables that point to the same object, they are not creating new objects but just making references to the other object right?
    \m/\m/

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Huh?

    If you mean something like this, it works:
    Code:
    System.Collections.Hashtable table1 = new System.Collections.Hashtable();
    System.Collections.Hashtable table2 = table1;
    table1.Add("keyString", "dataString");
    System.Console.Println(table2["keyString"]);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    myClass mClass = new myClass();

    Hashtable h1 = new hashtable();
    hashtable h2 = new hashtable();

    h1.add("class", mClass);
    h2.add("class", mClass);

    //now i make something like:
    h1["class"].SOmething = 5;

    //will now h2["class"].something be 5 too?
    \m/\m/

  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Yes, because you are storing a pointer (reference) to the object in the hashtable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width