title: Singleton pattern for a property in c#
body: <p>I am trying to adapt singleton policy for my CsvConfiguration Property.</p>
  
  <p>If the configuration is already available, just return the configuration. else, get the configuration and return the same and I am able to build this code.</p>
  
  <pre><code>    public Rootpdf pdfConfiguration
      {
          get
          {
              Rootpdf pdfConfiguration = null;
              try
              {
                  if (pdfConfiguration == null)
                  {
                      //retrieve the configuration file.
                      //load the configuration and return it!
                  }
                  else
                  {
                      return pdfConfiguration;
                  }
              }
              catch (Exception e)
              {
                  Log.Error("An error occurred while reading the configuration file.", e);
              }
  
              return pdfConfiguration;
          }
      }
  </code></pre>
  
  <p>Advantages (i hope): Whenever my pdfConfiguration is wanted, if already it is available, i can return it. Need not load the configuration file eachtime
  and calculate the configuration.</p>
  
  <p>My Query: The resharper! The resharper tells that the code </p>
  
  <pre><code>   if (pdfConfiguration == null) //The expression is always true.
  </code></pre>
  
  <p>Is it really a problem with resharper that it doesn't understand I am following this singleton pattern ?</p>
  
  <p>or</p>
  
  <p>Am I not following singleton pattern at all?</p>