When I read a line of C# code about delegate,I found it interesting in below code:
//other code goes here
delegate void DrawShape(Brush aBrush,Rectangle aRect);
//other code goes here
DrawShape DrawRectangleMethod;
DrawRectangleMethod=new DrawShape(aGraphics.FillRectangle);
MyDrawShape(DrawRectangleMethod);
//other code goes here
private void MyDrawShape(DrawShape theDelegate)
{/* */}
Big surprise the above code can compile without even a warning!!My question is that the signature of the delegate DrawShape have two parms--Brush ,Rectangle.While instantiate this delegate,there is only one parm--aGraphics.FillRectangle.I don't understand how this can work.
Thanks for everyone who can help.
Regards,
Sam