Click here to Skip to main content
15,888,066 members
Articles / Web Development / ASP.NET
Alternative
Tip/Trick

No More Session Variable Misspellings

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
22 Jun 2011CPOL 8.6K   4
I prefer to wrap my session variables like this:public class MySession { public string MyValue { get { return Convert.ToString(Session["MyValue"]); } set { Session["MyValue"] = value; } }}

I prefer to wrap my session variables like this:


C#
public class MySession {
  public string MyValue
  {
     get { return Convert.ToString(Session["MyValue"]); } 

     set { Session["MyValue"] = value; }
  }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Unknown
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalcool dude :) Pin
Patalancha-Sagar27-Jun-11 19:09
Patalancha-Sagar27-Jun-11 19:09 
GeneralReason for my vote of 4 yes i used to the same Pin
pankajupadhyay2923-Jun-11 1:02
professionalpankajupadhyay2923-Jun-11 1:02 
Generalyes i used to the same Pin
pankajupadhyay2923-Jun-11 1:02
professionalpankajupadhyay2923-Jun-11 1:02 
GeneralSee my alternate. It is like your alternate, except a few th... Pin
AspDotNetDev22-Jun-11 14:39
protectorAspDotNetDev22-Jun-11 14:39 
See my alternate. It is like your alternate, except a few things are handled automatically (e.g., prefixing, using property name, get and set methods, type conversion). It shortens the code significantly.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.