Hi Team,
I am using one Session variable to passing data between method in one page. For example: I am using Session["SourceType"] variable, which the value always changing depends on where the user want to view the content.
My question is, when I store another value into the same session variable (Session["SourceType"]) name, do I need to delete/remove first the old value or it will just overwritten the old value.
I hope that my question is clear and thanks in advance.
You can simply overwrite the old value when using Session variables. Just remember to cast it to proper type when reading it back.It will overwrite it.
it will overwrite the data if used like Session["sourceType"] = "new value"
however if you have the SourceType variable set and try to go
Session.Add("sourceType","value"); it will cause an error.
hth,
mcm
Thanks team,
So it means that the old value will be removed right. Because I don't want the old value just floating around the applications.
Thanks.
yes,
the .net Garbage Collector will remove the old value from memory when you assign the same variable another value.
mcm
0 comments:
Post a Comment