session question

  • Thread starter Thread starter Guest
  • Start date Start date
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 ???
 
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
 
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 ????
 
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!
 
Back
Top