title: Does making singleton class sealed really help in achieving goal of singleton pattern C# - Static Initialization (A thread safe solution)
body: <p>I know other threads exist regarding this question but I couldn't find satisfactory answer for this. Why singleton class needs to be sealed in C# ? (To clarify my question)Does making it sealed really help it achieving goal of singleton (only one instance) ?</p>
  
  <p>I have added more clarification about what I am wanting to know and trying to find reason for, hope readers understand what I am trying to discuss.</p>
  
  <p>I am talking about MSDN article's thread safe solution : 
  <a href="https://msdn.microsoft.com/en-us/library/ff650316.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/ff650316.aspx</a>. </p>
  
  <p>In this article first they give solution which is not thread safe, then they give another solution using static initialization to make it thread safe and in that solution they make class: sealed</p>
  
  <p>As per MSDN's explanation -- The class is marked sealed to prevent derivation, which could add instances. For a discussion of the pros and cons of marking a class sealed, see [Sells03].</p>
  
  <p>When I tried to figure why they used Sealed in static initialization approach, only thing I could figure is: as they wanted to prevent additional instantiation they made it sealed (this only prevents instantiation done through derivation, nested sub class derivation could create additional instances but by using Sealed it doesn't prevent nested class from creating additional instances.) to achieve goal of singleton. If using sealed doesn't prevent additional instantiation through other ways then why use it ?</p>
  
  <p>Below is the MSDN's thread safe solution:</p>
  
  <p>public sealed class Singleton
  {
     private static readonly Singleton instance = new Singleton();</p>
  
  <p>private Singleton(){}</p>
  
  <p>public static Singleton Instance
     {
        get 
        {
           return instance; 
        }
     }
  }</p>
  
  <p>My question is does MSDN's thread safe solution achieve goal of singleton by making it sealed? They made class sealed to prevent instantiation through derivation but that doesn't stop instantiation done through other ways. See my example below:</p>
  
  <pre><code>     public sealed class Singleton
       {
        private static readonly Singleton instance = new Singleton();
  
        private Singleton() { }
  
        public static Singleton Instance
        {
          get
          {
              return instance;
          }
        }
  
        public class nestedSingleton
        {
          public nestedSingleton()
          {
              Singleton moreThanOneObject = new Singleton();
          }
        }
      }
  </code></pre>