fork download
  1. using System;
  2.  
  3. class Res : IDisposable
  4. {
  5. public Res(){
  6. Console.WriteLine("Lock resource");
  7. }
  8. public void Dispose(){
  9. Console.WriteLine("Release resource");
  10. }
  11. public bool P{
  12. private get{return true;}
  13. set{throw new Exception("hi there!");}
  14. }
  15. }
  16.  
  17. public class Test
  18. {
  19. public static void Main()
  20. {
  21. using (var res = new Res(){P=true})
  22. {
  23. //do something
  24. }
  25. }
  26. }
Runtime error #stdin #stdout 0.04s 36448KB
stdin
Standard input is empty
stdout
Lock resource