Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ()=> mean(c#3.0) [duplicate]

Tags:

c#-3.0

Possible Duplicate:
What does () => mean in C#?

Hi Everybody,

This is my first question in stackoverflow.

I have encounter something as

() => SomeClass.SomeMethod(param1, param2)

This is entirely new to me and I cannot fathom what it is, what we call it, what it does,

how it works etc.

What I am looking for is an explanation for the same with a simple example which can be

understandable easily and I can implement it in my program. It will be nice if I can get

the real time scenario for this implementation.

I am using C#3.0 with dotnet framework 3.5.

Many thanks in advance.


1 Answers

Lambdas page on MSDN is quite helpful with the syntax.

And yes, ()=>GetSomething() is an expression lambda that takes no parameters and returns something. The other lambda flavour is a statement lambda, which is an anonymous function that does not return anything - i.e. a void function.

Both can take any number of parameters, including none.

like image 66
Igor Zevaka Avatar answered Feb 27 '26 02:02

Igor Zevaka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!