Thoughts on the default partial field in the CS code file in Asp.net 2.0 background

Source: Internet
Author: User

As we all know, the partial local class is a new product of. NET 2.0. It allows the implementation of the class to be split and stored in different CS files. When using the partial local class, you must use the "partial" Explicit declaration.

Originally, we thought that the "partial" keyword is not used when we do not use the partial local class. However, every time we create a web form file, VS 2005 will automatically go to the CS backgroundCodeUse the following method to declare the Form class in the file:

Public partial class itgao_com: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{

}
}

It is a bit confusing, so I will delete the partial keyword in the above Code and want to see if this partial is a general setting for vs2005 to adapt to local classes. Result 1: After debugging, the system prompts:

The partial modifier is missing in the declaration of the "itgao_com" type of error 1; other partial declarations of this type exist D: \ net2.0 learning \ Generic and other new features \ WEB \ csharp20 \ itgao_com.aspx.cs 12 14 d :\... \ WEB \

Is that true?ProgramIn other parts of the project, what about "the other half" of partial class itgao_com? No second itgao_com class was found throughout the project, except for the front-end aspx file corresponding to itgao_com. It seems that I am wrong.

After some thought, I suddenly realized. Asp.net itself allows programs to be written directly on the ASPX page. Isn't that the "Other Half" of the partial class itgao_com I'm looking? Haha. In this case, the Asp.net 1.x version has long been a prototype of the partial local class.

Asp.net 1. in Version X, the front-end page and the backend CS file can write programs at the same time. Therefore, I think Asp.net 1. version X already uses the partial mechanism, but it is limited to the partial between the ASPX page and the corresponding CS, and 2.0 extends it to all classes.

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.