title: Best way to define constant in asp.net
body: <p>Which of below 2 method is better to declare constant/config driven variables in asp.net from coding standing perspective, from architecture perspective.</p>
  
  <p>Type1-</p>
  
  <pre><code>class Constants
  {
      public static string ConnectionString
      {
          get
          {
              //Get the connection string value from web.config
              if (ConfigurationManager.AppSettings["ConnectionString"] != null)
              {
                  return ConfigurationManager.AppSettings["ConnectionString"];
              }
              else
              {
                  return string.Empty;
              }
          }
      }
  }
  </code></pre>
  
  <p>Type 2-</p>
  
  <pre><code>class Constants
  {
      public static string ConnectionString = ConfigurationManager.AppSettings["ConnectionString"] != null ?
                                                  ConfigurationManager.AppSettings["ConnectionString"] : string.Empty;
  }
  </code></pre>
  
  <p>Is there any better way to do? Is it better to use <em>property</em> or use a <em>public variable</em>?</p>