Reference types in Session

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top