fork download
  1. using System;
  2.  
  3. public class A
  4. {
  5. public virtual void f1()
  6. {
  7. Console.WriteLine("A.f1() _ base");
  8. }
  9. }
  10.  
  11. public class B: A
  12. {
  13. public override void f1()
  14. {
  15. Console.WriteLine("B.f1()");
  16. }
  17.  
  18. public void f1(string messaggio)
  19. {
  20. Console.WriteLine($"B.f1(<{messaggio}>)");
  21. base.f1();
  22. }
  23. }
  24.  
  25. public class Test
  26. {
  27. public static void Main()
  28. {
  29. // your code goes here
  30. A a,n;
  31. B b;
  32. a=new A();
  33. b=new B();
  34. n=new B();
  35. a.f1();
  36. b.f1();
  37. b.f1("Nuovo");
  38. n.f1();
  39. }
  40. }
Success #stdin #stdout 0.01s 29664KB
stdin
Standard input is empty
stdout
A.f1() _ base
B.f1()
B.f1(<Nuovo>)
A.f1() _ base
B.f1()