What is anonymous method in c#? Explain | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is anonymous method in c#? Explain

please could explain the anonymous method in c#?

29th Dec 2018, 8:15 PM
Shivanand Nagarabetta
Shivanand Nagarabetta - avatar
1 Answer
+ 2
In C#2.0 When you must use a function, but you need to use it once only, you define an anonymous function, in this way: ageList.Find(delegate(int age) {return age>18}); In C#3.0 a simpler syntax called lambda expression is implemented, for example: ageList.Find( age => age>18); Reference: https://www.c-sharpcorner.com/article/anonymous-methods-and-lambda-expressions-in-c-sharp/
31st Dec 2018, 11:35 AM
Gordon
Gordon - avatar