What does it mean () => mean (C # 3.0)

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

Hello everybody,

This is my first stackoverflow question.

I ran into something like

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

This is completely new to me, and I can’t understand what it is, what we call it, what it does,

how it works, etc.

What I'm looking for is an explanation of the same with a simple example that might be

understandable, and I can implement it in my program. It will be good if I can get

real-time script for this implementation.

I am using C # 3.0 with dotnet 3.5 platform.

Thank you very much in advance.

+3
source share
3 answers

The Lambdas MSDN page is quite useful with syntax.

, ()=>GetSomething() - lambda, - . - , , , .. void.

, none.

+2

, -. , "inline".

, LINQ :

myTable.Where(eleme=>elem.qty>=10);

leme=>elem.qty>=10 Where.

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

0

, Action. ( ) http://msdn.microsoft.com/en-us/library/system.action.aspx

(s) => SomeMethod(s);

:

(x) => {
   DoSomething(x);
   if(x.SomeValue == requiredValue){
      x.SomeOtherValue = true;
   }
}

Action<T> .

0
source

Source: https://habr.com/ru/post/1751134/


All Articles