How do i maintain a variable that has been assigned once in a class to remain the sam

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charindal
    New Member
    • Dec 2009
    • 17

    How do i maintain a variable that has been assigned once in a class to remain the sam

    I am developing a database system and i would want the user to be able to select the servername at login level. this information is passed into a class which holds the connection string. every function that connects to the database refrences this class. i would like to be able to assign these values once at login and then be able to re use them over and over until the user logouts.

    thank you
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    declare the variable as static

    Comment

    • sashi
      Recognized Expert Top Contributor
      • Jun 2006
      • 1749

      #3
      Hi there,

      You can also consider using ReadOnly property, kindly refer to below code segment.

      Code:
          public string ServerName
          {
              get
              {
                  return m_ServerName;
              }
          }

      Comment

      Working...