草庐IT

BinaryOperation

全部标签

c# - 即使签名匹配,也无法将一种类型的委托(delegate)分配给另一种

我病态的好奇心让我想知道为什么以下失败://declaredsomewherepublicdelegateintBinaryOperation(inta,intb);//...inamethodbodyFuncaddThem=(x,y)=>x+y;BinaryOperationb1=addThem;//doesn'tcompile,andcastingdoesn'tcompileBinaryOperationb2=(x,y)=>x+y;//compiles! 最佳答案 C#对“结构”类型的支持非常有限。特别是,您不能简单地从一种委托