convert from static variables to session

Discussion in 'ASP .Net' started by nicepg, Jun 25, 2006.

  1. nicepg

    nicepg Guest

    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



    --
    nicepg
    ------------------------------------------------------------------------
    Posted via http://www.codecomments.com
    ------------------------------------------------------------------------
    nicepg, Jun 25, 2006
    #1
    1. Advertising

  2. 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
    "nicepg" wrote:

    >
    > 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
    >
    >
    >
    > --
    > nicepg
    > ------------------------------------------------------------------------
    > Posted via http://www.codecomments.com
    > ------------------------------------------------------------------------
    >
    >
    =?Utf-8?B?Q2FsdmluIEtE?=, Jun 26, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    923
  2. SaravanaKumar
    Replies:
    6
    Views:
    9,357
    Tony Morris
    Oct 19, 2004
  3. Neviton
    Replies:
    9
    Views:
    442
    Alf P. Steinbach
    Sep 17, 2007
  4. Martin Wells

    Static inline functions with static local variables

    Martin Wells, Oct 6, 2007, in forum: C Programming
    Replies:
    10
    Views:
    691
    Army1987
    Oct 8, 2007
  5. Hicham Mouline
    Replies:
    5
    Views:
    2,341
    James Kanze
    Dec 19, 2008
Loading...

Share This Page