convert from static variables to session

N

nicepg

Hi,

i m new in C#, and i m trying to prgramm a calculator program in web
application.

My program work very well using a static variables but i need to change
these variables to session variables..

my static variables are:

public static double num1=0,num2=0;
public static string prevOp="";

could you pleas show me how to do that?

thank you in advance
 
G

Guest

Hi,
Have you tried:

Session["num1"] = 0;
Session["num2"] = 0;
Session["prevOp"] = string.Empty;
....

To use the assigned values, do this:

if (Session["num1"] != null)
{
decimal num1 = Convert.ToDecimal(Session["num1"]);
}
....

Hope that helps.
Calvin
 

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
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top