title: C# - Are Static Properties of a Class Initialised Every Time that Class is Initialised?
body: <p>I'm currently looking at some old code and I've come across a class that is using a private static property which is created with a default value and never modified; something like this -</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Foo
  {
      private static readonly string ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnection"].ToString();
  
      public Bar GetBar(int barId)
      {
          // get bar using "ConnectionString" above
      }
  }
  </code></pre>
  
  <p>So my question is - Is there any benefit to <code>ConnectionString</code> being static? i.e. Is <code>ConfigurationManager.ConnectionStrings["SqlConnection"].ToString();</code> run every time <code>new Foo()</code> is run thus making the static value of the property redundant as it is overwritten every time the class is initialised? </p>