fork download
  1. using System;
  2.  
  3. class B {
  4. private B() { }
  5. }
  6.  
  7. class C: B {
  8. class E: Exception { }
  9. static C instance;
  10. public static C Instance() {
  11. try {
  12. new C();
  13. } catch(E) { }
  14. GC.Collect();
  15. GC.WaitForPendingFinalizers();
  16. return instance;
  17. }
  18. static int Throw() {
  19. throw new E();
  20. }
  21. C(): this(Throw()) { }
  22. C(int i): this() { }
  23. ~C() {
  24. instance = this;
  25. }
  26. }
  27.  
  28. static class D {
  29. static void Main() {
  30. Console.WriteLine(C.Instance().GetType());
  31. }
  32. }
Success #stdin #stdout 0.01s 131520KB
stdin
Standard input is empty
stdout
C