hello ,
please clear this concept.
Thanks
Niraj
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 17, 2014, 1:35 AM EST
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.