c# - Why can my lambda expressions not use the same internal variable? -


I'm new to C # and it was working with lambda values.

My question is why does the parameter list not have the same variable in each of them? If you do note in print (q is variable) and in square (there is variable in c) and there are variables in add (x, y) and in ISL constanten (f variable is) what if i want to make them all the parameter The name, such as pizza can be done. It was on the tutorial I was looking at My second case is that if you make better code instead of using regular functions?

I think this is called Lambda Expression. I heard some different names on the tutorial video.

Question: Can only one variable be used in different lambda signage?

I want to know if I can say that use all the variable symbols in my lambda expressions

  verb & lt; Int & gt; Print = index = & gt; Console.WriteLine (index);   

Code:

  Action & lt; Bool & gt; Print = q = & gt; Console.WriteLine (Q); Funk & lt; Double, double & gt; Class = c = & gt; C * C; Funk & lt; Double, double, double & gt; Plus = (x, y) = & gt; x + y; In the & lt; Double & gt; IsLessThanTen = f = & gt; F & LT; 10; Print (Haistyntan (square (plus (4, 5))); Console.ReadKey (); To answer your second question,    

An advantage of using delegates in this way It is that the function represented by the delegate can be changed at runtime. For example, suppose you have a representative for multiply

  function  A * B; And suppose, instead of multiplying if you have a certain condition, you need to have a crazy need to divide.  

Then ...

  if (crazy demand iets) {majority = (a, b) => A / B; }   

Now, everywhere you multiply, it will actually split.

In this example, think of multiply as a variable, as a function and as a function, to change the value of this "variable" You must assign to a function that matches the signature you set.

I used representatives in the past while using a variety of databases in a solution. Depending on the delegates would be different if the database was Oracle or MS SQL.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -