Documenting the extension methods in C #

Source: Internet
Author: User

extension methods in C #.

  1. System comes with the type, we can not go to modify;
  2. It takes a lot of effort to modify the source code and may cause errors;
  3. We just need a few or fewer ways to modify the source code is time consuming and laborious;
  4. The extended class is sealed and cannot be inherited; (even if it's not sealed, we can't write a subclass because we need a method, so it's not object-oriented)

Three elements of an extension method:

  1. The extension method must be in a static class;
  2. The extension method must be a static method;
  3. The argument list of an extension method must begin with this, followed by the extension class, and then the parameter required by the method;

Documenting the extension methods in C #

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.