Possible Duplicate:
C#: Difference between ‘ += anEvent’ and ‘ += new EventHandler(anEvent)’
Let us have this delegate :
delegate int Process (int x ,int y) ;
and this method :
int Add (int x , int y)
{
return x+y ;
}
My queston :
what is the difference between :
Process MyProcess = Add ;
and :
Process MyProcess = new Process (Add) ;
In C# 1.x only the second version would compile.
C# 2.0 added implicit method group conversions which allows you to write the first version. The two are equivalent. Sometimes it is necessary to use the more explicit form in the case that there is ambiguity.
See the section Delegate inference from Jon Skeet’s article Delegate changes for more information.