C # Getting Started classic lambda

Source: Internet
Author: User

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 6 namespaceLambdasample7 {8     class Program9     {Ten         Static voidMain (string[] args) One         { A             int[] Myintarray = {1,2,3,4,5 }; -             //Accumulator calculates the sum of an array -             intresult = Myintarray.aggregate ((Parama, paramb) = Parama +paramb); the             intRESULT1 = myintarray.aggregate<int> (Parama, paramb) = Parama +paramb); -             intRESULT2 = myintarray.aggregate<int,int> (0, (Parama, paramb) = Parama +paramb); -             //recursively computes the sum of an array -             intRESULT3 = count (5); +Console.WriteLine ("The Result is:"+result); -Console.WriteLine ("The Result1 is:"+result1); +Console.WriteLine ("The Result2 is:"+result2); AConsole.WriteLine ("The RESULT3 is:"+RESULT3); at  -             string[] Mystrarray = {"Admin"," Change","Bypage" }; -             //string array splicing what to ask -             stringstrresult = Mystrarray.aggregate ((Parama, paramb) = Parama +" "+paramb); -             //string Array string total length calculation -             intRESULT4 = mystrarray.aggregate<string,int> (0, (A, B) = + A +b.length); in             //string Array stitching 2, adding the string "Some curries:" -             stringSTRRESULT1 = mystrarray.aggregate<string,string> ("Some Curries:", (A, B) = + A +" "+b); to             //string Array string total length calculation 2 hovertree.com +             intRESULT5 = mystrarray.aggregate<string,string,int> ("Some Curries:", (A, B) = + A +" "+ B, a =a.length); -Console.WriteLine ("The strresult is:"+strresult); theConsole.WriteLine ("The Result4 is:"+result4); * Console.WriteLine (STRRESULT1); $Console.WriteLine ("The RESULT5 is:"+result5);Panax Notoginseng Console.readkey (); -         } the  +         Static intCountintN) A         { the             if(n = =1) +             { -                 return 1; $             } $             returnn + count (N-1); -         } -     } the}

Transferred from: http://hovertree.com/h/bjaf/jf9yeju1.htm

Reference: C # Lambda Instance code in the in-depth lambda expression C # generics detailed description

Development technical Article collection: Http://www.cnblogs.com/sosoft/p/kaifajishu.html

C # Getting Started classic lambda

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.