Невозможно назначить делегата одного типа другому, даже если подпись соответствует

Мое болезненное любопытство заставляет меня задуматься, почему следующее не работает:

// declared somewhere
public delegate int BinaryOperation(int a, int b);

// ... in a method body
Func<int, int, int> addThem = (x, y) => x + y;

BinaryOperation b1 = addThem; // doesn't compile, and casting doesn't compile
BinaryOperation b2 = (x, y) => x + y; // compiles!
11
задан nawfal 20 December 2013 в 14:25
поделиться