hello ,
please clear this concept.
Thanks
Niraj
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 17, 2014, 6:35 AM
An example may make this somewhat metaphysical definition easier to grasp:
delegate int Transformer(int i);
Transformer cube = delegate(int i) { return i * i * i; };
Console.WriteLine(cube(5)); // 125
So here the anonymous method is compatible with the Transformer delegate type because it takes a single int parameter and returns an int.
Consequently, when you assign the anonymous method to the Transformer variable, cube, it's immediately converted to the Transformer delegate type.
You can then invoke the anonymous method via the delegate and cube(5) produces, as expected, 125.