C # Lambda learns a

Source: Internet
Author: User

Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks;            Namespace delegatedemo1{class Program {static void One () {Console.WriteLine ("one");        throw new Exception ("Error in one");        } static void () {Console.WriteLine ("n");            } static void Main (string[] args) {string mid = ", middle part,";            /*func<string, String>: Accepts a string argument, returns a string in this anonymous method cannot use Break,goto,continue to jump outside of the function, nor to jump inside                func<string, string> Anondel = delegate (string param) {param + = mid;                param + = "and this is End";            return param;            };            Console.WriteLine (Anondel ("Start")); /*lambda =&gt: The required parameters are listed on the left (param) lambda +: The right defines the code that assigns the method implementation of the lambda variable */func<str ing, string> lambda = param => {param + = mid;                param + = "and this is End";            return param;            };            Console.WriteLine (Anondel ("lambda")); Lambda a parameter compiler adds an implicit return statement func<string, string> Oneparam = s = = string.            Format ("Change uppercase {0}", S.toupper ()); Add the return statement shown func<string, string> oneparamr = s = = {return string.            Format ("Change uppercase {0}", S.toupper ());            };            Console.WriteLine ("Oneparam is" + Oneparam ("Test"));            Lambda two parameter compiler adds an implicit return statement func<double, double, double> towparams = (x, y) + x * y; Add the return statement shown func<double, double, double> TOWPARAMSR = (x, y) + = {Retur            n x * y;            };            Console.WriteLine ("Towparams is" + towparams (3,2));        Console.readkey (); }    }}

C # Lambda learns a

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.