fork download
  1. using System;
  2.  
  3. class ClaseA
  4. {
  5. protected virtual void F()
  6. {
  7. Console.WriteLine ("X.F");
  8. }
  9.  
  10. protected virtual void F2()
  11. {
  12. Console.WriteLine ("X.F2");
  13. }
  14. }
  15.  
  16. class ClaseB : ClaseA
  17. {
  18. sealed protected override void F()
  19. {
  20. Console.WriteLine ("Y.F");
  21. }
  22.  
  23. protected override void F2()
  24. {
  25. Console.WriteLine ("X.F3");
  26. }
  27. }
  28.  
  29. class ClaseC : ClaseB
  30. {
  31. // Attempting to override F causes compiler error CS0239
  32. // protected override void F() { Console.WriteLine ("C.F"); }
  33.  
  34. // Overriding F2 is allowed
  35. protected override void F2()
  36. {
  37. Console.WriteLine ("Z.F2");
  38. }
  39.  
  40. public static void Main ()
  41. {
  42.  
  43. }
  44. }
Success #stdin #stdout 0.01s 33528KB
stdin
Standard input is empty
stdout
Standard output is empty