ViIvanov

C# 4/5 Method groups

May 7th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. class C<X, Y> { }
  2.  
  3. static class Program
  4. {
  5.   static void M<X, Y, Z>(C<X, Y> c, System.Func<Y, Z> m) { }
  6.  
  7.   static int E(this object o, int v) { return v; }
  8.  
  9.   static void Main() {
  10.     var o = default(object);
  11.     M(default(C<int, int>), o.E);
  12.   }
  13. }
  14.  
  15. // error CS1502: The best overloaded method match for 'Program.M<int,int,int>(C<int,int>, System.Func<int,int>)' has some invalid arguments
  16. // error CS1503: Argument 2: cannot convert from 'method group' to 'System.Func<int,int>'
Advertisement
Add Comment
Please, Sign In to add comment