fork download
  1. using System.IO;
  2. using System;
  3.  
  4. abstract class A
  5. {
  6. public void Testme(A other)
  7. {
  8. Console.WriteLine("value from this: " + Value() + " value from other: " + other.Value());
  9. }
  10.  
  11. protected abstract string Value();
  12. }
  13.  
  14. class B : A
  15. {
  16. protected override string Value()
  17. {
  18. return "B class";
  19. }
  20. }
  21.  
  22. class C : A
  23. {
  24. protected override string Value()
  25. {
  26. return "C class";
  27. }
  28. }
  29.  
  30.  
  31.  
  32. class Program
  33. {
  34. static void Main()
  35. {
  36. B b = new B();
  37. C c = new C();
  38.  
  39. b.Testme(c);
  40. }
  41. }
  42.  
  43. // value from this: B class value from other: C class
Success #stdin #stdout 0.02s 34792KB
stdin
Standard input is empty
stdout
value from this: B class value from other: C class