Variables C#

F

Franck

I have an application that i just found a big problem. i used Static
variable thinking all instance of my application would have his own
variable. I doesn't seems to. I thought it would have been like
multiple instance of C# app under windows application but doesn't
seems so,

So my question is. What is the equivalent of static variable in
Asp.net. i know there is session variables but my logic is already
implemented based as static is global to my whole application. so if
it's just a matter to change the static word to something else it
would be the best

thank you.
 
F

Franck

I forgot to said that i had found Session[""] variables but they are
instantiate at the begining. i wonder how can i declare them as type
(string,bool,int32)
 
B

bruce barker

make a static class:

public class MySession
{
public string Var1
{
get { return (string) HttpContext.Current.Session["Var1"]; }
set { HttpContext.Current.Session["Var1"] = value; }
}
}

you really should add code to handle lost session, or a read before a set.


-- bruce (sqlwork.com)
 

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,777
Messages
2,569,604
Members
45,206
Latest member
SybilSchil

Latest Threads

Top