Singleton.cs 452 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace CScript.Utilities
  6. {
  7. public class Singleton<T> where T : new()
  8. {
  9. static T instance;
  10. public static T Instance
  11. {
  12. get
  13. {
  14. if (instance == null)
  15. {
  16. instance = new T();
  17. }
  18. return instance;
  19. }
  20. }
  21. }
  22. }