Singleton`1 where T.cs 233 B

1234567891011121314
  1. using System;
  2. public class Singleton<T> where T : class, new()
  3. {
  4. public static T Instance
  5. {
  6. get
  7. {
  8. return Singleton<T>._instance;
  9. }
  10. }
  11. private static readonly T _instance = Activator.CreateInstance<T>();
  12. }