MVC new Syntax anonymous method

Source: Internet
Author: User

I. Simple anonymous method

1.0 rules for how anonymous methods are written:

delegate (the parameters, format and type of the anonymous method are defined by the programmer himself according to the business logic) {Function's method body code}

At the bottom, write the anonymous method parameter written using Deledate

Two. Small practice examples and LANBDA expression inference

Small summary: 1. If there is only one argument, you can omit the parentheses, leaving only the parameter name, and if the number of arguments is greater than one, you must

Keep parentheses for example (pig,dog=>true)

2. You can omit {} and the last semicolon when there is only one aunt in the method body, and if there is a return value you can omit return

3. When the method body has multiple lines of code can not omit {}, if there is a return value can not omit the return

1

Three. Extension methods

1.0 features of the extension method

1. This method must be dead static class

2. This method must be in a static class

3. The first parameter of this method must begin with this, and the specified method is the extension on which type

MVC new Syntax anonymous method

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.