fork download
  1. using System;
  2.  
  3. public class Base {};
  4. public class Derived : Base {};
  5.  
  6. public static class Extensions {
  7. public static void Foo(this Base x) { Console.WriteLine("Base.Foo"); }
  8. public static void Foo(this Derived x) { Console.WriteLine("Derived.Foo"); }
  9. }
  10.  
  11. public static class Program {
  12. public static void Main(string[] args) {
  13. Base x = new Derived();
  14. x.Foo();
  15. (x as Derived).Foo();
  16. }
  17. }
  18.  
Success #stdin #stdout 0.02s 34800KB
stdin
Standard input is empty
stdout
Base.Foo
Derived.Foo