Class Extension Method

Source: Internet
Author: User

I haven't written a blog post for a long time, and I haven't written much since I got it. I think it's good to introduce a tips today.

To extend a class, a method can be written under another class, but this class must be a static class. The following is a simple implementation.

First, you must have your own extended class. I just wrote it to implement this extended method function.

/// <Summary>
/// Class of the method to be extended
/// </Summary>
Public class ExClass
{

}

With the class to be extended, you need to write the extension method later. I still think it looks nice.

650) this. width = 650; "src =" http://img1.51cto.com/attachment/201307/105918328.jpg "title =" Capture. JPG "/>

In this way, you will be given an extension method for the class of the extension method, but I tried it. This class must be static. You can try it. If not, you can return it to me, everyone makes common progress.

The next step is to call the Main function.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/205R31427-1.jpg "title =" Capture. JPG "/>

In this case, OK. I hope you will be able to learn more if you don't know.

This article from the "life pursuit" blog, please be sure to keep this source http://hacjj.blog.51cto.com/3843027/1242883

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.