fork download
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. var foo = Foo.Singleton;
  8. //Output:
  9. //Instance ctor
  10. //Static ctor
  11. }
  12. }
  13.  
  14. public class Foo
  15. {
  16. public static Foo Singleton = new Foo();
  17.  
  18. static Foo()
  19. {
  20. Console.WriteLine("Static ctor");
  21. }
  22.  
  23. public Foo()
  24. {
  25. Console.WriteLine("Instance ctor");
  26. }
  27. }
Success #stdin #stdout 0.02s 15488KB
stdin
Standard input is empty
stdout
Instance ctor
Static ctor