Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Variables C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Franck - 12 Feb 2008 19:26 GMT
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.
Franck - 12 Feb 2008 19:30 GMT
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)
bruce barker - 12 Feb 2008 21:14 GMT
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)

> 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
[quoted text clipped - 9 lines]
>
> thank you.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.