Hi
How to assign Session Variable as int
Thanks
Hi
How to assign Session Variable as int
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mohamed Azarudeen ZRank #297 · 8.5K reputationPosted May 24, 2023, 10:42 AM EDT
Here's an example of how you can assign an
intvalue to a session variable:// Set session variable int value = 123; Session["MyVariable"] = value;In the above example, the session variable named "MyVariable" is assigned the value of
123.Later, when you need to retrieve the value from the session variable, you can cast it back to an
int:// Get session variable int retrievedValue = (int)Session["MyVariable"];In this case, the value stored in the session variable "MyVariable" is cast back to an
intand assigned to theretrievedValuevariable.Arnab MukherjeeRank #879 · 2.5K reputationPosted May 24, 2023, 12:29 PM EDT
// Storing the value in Session int i=10; Session["VariableName"]=i; //Get int value from Session int j =(int) Session["VariableName"];