fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. class Base {
  6. }
  7. class Derived : Base {
  8. public string X {get;set;}
  9. }
  10.  
  11.  
  12.  
  13. public static void Main()
  14. {
  15. Func<Derived,object> original = d => d.X;
  16. Func<Base,object> converted = b => original((Derived)b);
  17. Base obj = new Derived {X = "hello"};
  18. Console.WriteLine(converted(obj));
  19. }
  20. }
Success #stdin #stdout 0.03s 24144KB
stdin
Standard input is empty
stdout
hello