c# - What is the different in the lambda expression from group1 and group2? -


What is the difference between group 1 and group 2 in the following syntax? I have started using these types of expressions and I think that is a representative and looks like a function (for the most part) and then I look at group 1 ( = & gt; ) with this syntax and it is not certain that Func & lt; & Gt; Only two arguments should be taken, but in group 1 example it takes three variables why is it? Group 1 Action & lt; Bool & gt; print1 = q = & gt; Console.WriteLine (Q); & Lt; Integer & gt; printInt = q = & gt; Console.WriteLine (Q); Funk & lt; Double, double & gt; Class 1 = c = & gt; C * C; Funk & lt; Double, double, double & gt; Add1 = (x, y) = & gt; x + y; In the & lt; Double & gt; isLessThanTen1 = f = & gt; F & LT; 10; Group 2 function & lt; String, string & gt; Convert = delegate (strings) {returns s. Towapper (); }; Without the need for a representative, Group 1 is a rhythmic way to create a representative (

). This is "Favorite" because it is small and easy to read

  • Action & lt; & Gt; A representative who takes argument (or multiple) and gives zero
  • Funk & lt; & Gt; A representative who takes argument (or multiple) and gives something
  • Valid & lt; & Gt; A representative who takes logic (or multiple) and returns bool

    In other words

      funk & lt; int, null & gt; == Action & lt; Int & gt;   

    and

      Funk & lt; Int, bool & gt; == prediction & lt; Int & gt;   

    In the linked MSDN page, there are other surcharges for the function & lt; & Gt; Take a different amount of that parameter, for example, a version that accepts 4 parameters.

    One of the best resources on the topic. It gives a nice history of delegates and syntax changes in each version of C #.

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 -