title: Storing global variables in c#?
body: <p>I basically have created a class which when a user logs into a website it then queries the database and stores some settings in a List (So I have key/pair values).</p>
  
  <p>The reason for this is because I want to always be able to access these settings without going to the database again.</p>
  
  <p>I put these in a class and loop through the fields via a SQL query and add them to the list.</p>
  
  <p>How can I then access these variables from another part of the application? or is there a better way to do this? I'm talking server side and not really client side.</p>
  
  <p>Here is an example of what I had at the moment:</p>
  
  <pre><code>public static void createSystemMetaData()
  {
      string constring = ConfigurationManager.ConnectionStrings["Test"].ConnectionString;
      SqlConnection sql = new SqlConnection(constring);
      sql.Open();
  
      SqlCommand systemMetaData = new SqlCommand("SELECT * FROM SD_TABLES", sql);
      //Set Modules
      using (SqlDataReader systemMetaDataReader = systemMetaData.ExecuteReader())
      {
          while (systemMetaDataReader.Read())
          {
              var name = systemMetaDataReader.GetOrdinal("Sequence").ToString();
              var value = systemMetaDataReader.GetOrdinal("Property").ToString();
              var Modules = new List&lt;KeyValuePair&lt;string, string&gt;&gt;();
              Modules.Add(new KeyValuePair&lt;string, string&gt;(name, value));
          }
      }
  }
  </code></pre>
  
  <p>Thanks</p>