session question

G

Guest

hello
In ASp.net application,there are two created session object was attatched to one object,if I remove one of session object , does the other keeps normal or destoryed ? Thanks In advance!!
Code like below
object a = new class()
session.add("A",a)
session.add("B",a)
....
session.remove("A")
Session["B"] = null ???
 
N

Natty Gur

Hi,

Both of session items points to the same object. If you change B it
affects A and if you remove B, A is still pointing to an object. The
assign object will be destroyed (by GC) just after no reference will
refer it.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
K

Kevin Spencer

Session is a Collection. If you add an element to it, or remove an element
from it, it affects no other element in the Collection. Adding and removing
objects to and from a Collection does nothing to the objects themselves. It
doesn't even move them in memory. It simply adds a reference (pointer) to
the object to the Collection.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

lzh_gladiator said:
hello:
In ASp.net application,there are two created session object was
attatched to one object,if I remove one of session object , does the other
keeps normal or destoryed ? Thanks In advance!!!
Code like below:
object a = new class();
session.add("A",a);
session.add("B",a);
....
session.remove("A");
Session["B"] = null ????
 
G

Guest

Hello
Thanks for your answers!But I want to know more about it.Does it mean remove a object from session simply remove refence itself only? this is quite resonable,but if i set the refenced session object to null, what will happen to other session object?Useful resource will more helpful!!Thanks sincerely!
 

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

Members online

No members online now.

Forum statistics

Threads
474,150
Messages
2,570,853
Members
47,394
Latest member
Olekdev

Latest Threads

Top