Reference types in Session

Discussion in 'ASP .Net' started by =?Utf-8?B?RHVuZGVhbGluZw==?=, Jan 19, 2006.

  1. I have just completed a walkthrough exercise in a MS book and noticed that
    while the instance of a new class was put into session when the page was
    created, it was only ever retrieved on subsequent postbacks (it was not
    placed back into a session variable at any point in the program).

    Is this because a class maintains just a reference to the object in Session,
    or am I missing something else?
     
    =?Utf-8?B?RHVuZGVhbGluZw==?=, Jan 19, 2006
    #1
    1. Advertising

  2. I think you got it.

    The value in the session is just a memory address pointing to the data on
    the HEAP. All references, whether you create a new var and assign it to the
    old, or pass it as a parameter, as all pointing to the same data on the
    heap, change one and you change all.

    Karl

    --
    http://www.openmymind.net/



    "Dundealing" <> wrote in message
    news:...
    >I have just completed a walkthrough exercise in a MS book and noticed that
    > while the instance of a new class was put into session when the page was
    > created, it was only ever retrieved on subsequent postbacks (it was not
    > placed back into a session variable at any point in the program).
    >
    > Is this because a class maintains just a reference to the object in
    > Session,
    > or am I missing something else?
     
    Karl Seguin [MVP], Jan 19, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sathyaish
    Replies:
    2
    Views:
    590
    Sathyaish
    May 22, 2005
  2. Soren Kuula
    Replies:
    2
    Views:
    564
    Henry S. Thompson
    Dec 1, 2005
  3. Jeremy Cowles

    STD types vs C++ intrinsic types

    Jeremy Cowles, Aug 18, 2003, in forum: C++
    Replies:
    5
    Views:
    1,888
    Bob Jacobs
    Aug 19, 2003
  4. Steve Knight
    Replies:
    2
    Views:
    761
    Steve Knight
    Oct 10, 2003
  5. Sam Kong
    Replies:
    12
    Views:
    294
    John G Harris
    Oct 17, 2006
Loading...

Share This Page