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

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top