title: How to make a generic singleton base class C#
body: <p>I am trying to create a generic singleton base class like</p>
  
  <pre><code>public class SingletonBase&lt;T&gt; where T : class, new()
  {
      private static object lockingObject = new object();
      private static T singleTonObject;
      protected SingletonBase()
      {
  
      }
  
      public static T Instance
      {
          get
          {
              return InstanceCreation();
          }
      }
      public static T InstanceCreation()
      {
          if(singleTonObject == null)
          {
               lock (lockingObject)
               {
                    if(singleTonObject == null)
                    {
                         singleTonObject = new T();
                    }
               }
          }
          return singleTonObject;
      }
  }
  </code></pre>
  
  <p>But I have to make constructor as public in derived one.</p>
  
  <pre><code>public class Test : SingletonBase&lt;Test&gt;
  {
      public void A()
      {
  
      }
      private Test()
          : base()
      { }
  }
  </code></pre>
  
  <p>Compilation Error:</p>
  
  <blockquote>
    <p>'Test' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'Test'</p>
  </blockquote>
  
  <p>How can I achieve this?</p>