c# - Usage Of Lambda Expression in Practical Programming -


I am an experienced developer in C # and I have been working on the LOB application for the last 7 years, I have used it for its use. There are some problems in understanding. Lambda expression in programming

As far as I understand, it is useful in working with LINQ (group, selection, ou ... etc).

  • We can pass the Lambda expression in any form as a logic, so it can be used in place of a representative or anonymous function or general work.
  • We can create generic lambda functions that can logic and any datatype as any datatype variable, eg

      MyFirstLambdaFunc ((VAL1, Val2) => VAL1 + val2) Public R MyFirstLambdaFunc (Func lambdaexpression, T x, TY) {R Result = lambdaexpression (X, Y); Return result;  
  • Coding can be compact

  • The question now is:

    1. Are there any other benefits?
    2. When we pass the Lambda expression as a function, can we only pass a line operation?
    3. Do anyone have some case studies or some practical examples? Thanks in advance

      Harish Bhattabhatta

  • < P> For non-expression trees, you can definitely write multi-line lambda quote. Just this morning I wrote with some of my lines:

      var query = foo.Select (x => {string text = x.value; int delimitedIndex = text.IndexOf ('' ) To return int.Parse (text.Substring (0, delimitedIndex);});  

    Lambda expressions can be useful almost anywhere that you appropriate Simple implementation.

    To provide another case, suppose you want to start several threads to work on many values ​​(we ignore this fact that we have many threads Have been - The same technique can also be used for threads.) You can use something like this:

      foreach (string url in url) {// little carat cementix string url copy = Url; New thread ((=) = FetchUrl (urlCopy). Start ();}  

    This is normally difficult in a typed way - Parameterated Path to Start , but it is not normal, so it becomes misplaced. F is IMO.


    Comments

    Popular posts from this blog

    c++ - Linux and clipboard -

    Visual Studio 2005: How to speed up builds when a VSMDI is open? -

    booting ubuntu from usb using virtualbox -