fork download
  1. using System;
  2.  
  3. class Program
  4. {
  5. class Foo
  6. {
  7. public Foo()
  8. {
  9. Console.WriteLine("Building Foo");
  10. }
  11.  
  12. public int Bar
  13. {
  14. get
  15. {
  16. Console.WriteLine("Getting Foo.Bar");
  17. return 0;
  18. }
  19.  
  20. set
  21. {
  22. Console.WriteLine("Setting Foo.Bar: boom!");
  23. throw new Exception();
  24. }
  25. }
  26. }
  27.  
  28. static Foo foo2;
  29.  
  30. static Foo foo
  31. {
  32. get
  33. {
  34. Console.WriteLine("Getting foo");
  35. return foo2;
  36. }
  37.  
  38. set
  39. {
  40. Console.WriteLine("Setting foo");
  41. foo2 = value;
  42. }
  43. }
  44.  
  45. static void Main(string[] args)
  46. {
  47. try
  48. {
  49. foo = new Foo { Bar = 100 };
  50. }
  51. catch (Exception ex)
  52. {
  53. Console.WriteLine("Exception: {0}", ex);
  54. }
  55.  
  56. Console.WriteLine("Finished try/catch");
  57.  
  58. Console.WriteLine("foo initialized: {0}", foo != null);
  59. }
  60. }
  61.  
Success #stdin #stdout 0.04s 33968KB
stdin
Standard input is empty
stdout
Building Foo
Setting Foo.Bar: boom!
Exception: System.Exception: Exception of type 'System.Exception' was thrown.
  at Program+Foo.set_Bar (Int32 value) [0x00000] in <filename unknown>:0 
  at Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
Finished try/catch
Getting foo
foo initialized: False