WHIDBEY's primary experience (Partial type) Visual Studio 2005 [Whidbey] preemptive experience version [Express Beta 1] has a period of time, and free download on Microsoft's official website (download address: http: // Lab .msdn.microsoft.com / vs2005 /). I really like C # this new language. Maybe it can't say that it is a new life, it is a refining in the past language, maybe it is on the shoulder of the giant, so it looks so excellent. C # 2.0 accompanying the experience version brings us new language features (generics: generics: Iterat: partial class: local type; anonymous methods: anonymous method;), make us more easily writing a simple Bright code, of course, these new features give us a far more than simple and bright code. This only understands your experience in the process of our use. Both the 2003 and 2005 new WindowsApplication12003 and 2005 Solution Explorer will build a form of formal forms that inherited from System.Windows.Forms.Form class, which we compare two different IDE environments. How is the code of Form1. Select Form1.cs View Code 2003: Public Class Form1: System.Windows.Forms.Form {Private System.Windows.Forms.Button Button1; ///
Public Form1 () {// // Windows Form Designer Support for // InitializationComponent (); // // Todo: Add any constructor code after INITIALIZECOMPONENT calls //}
///
#REGION Windows Form Designer The code ///
///
Private void button1_click (object sender, system.eventargs e) {}} 2005: Partial class form1: form {public form1 () {initializecomponent ();}
Private void button1_click (Object sender, Eventargs e) {
}} I look at the code files in FORM1 in two environments. The code is very different in Form1. There is only one point in 2005. There is no definition for Button1, and there is no button1_click () obviously questionable. If we quickly found that Class Form1 was defined as partial, the new language feature local type of C # 2.0. Then we click on the show all files button on the 2005 IDE Solution Explorer, and you will find that more file1.designer.cs under Form1.cs is not in the 2003 environment, and we will find it. Another part of Class Form1 is defined. Partial class form1 {///
#Region Windows Form Designer Generated Code
///
#ndregion
Private system.windows.Forms.Button Button1;} It is now like 2005 to the form of Form1 seems to be all, 2005 in Form1.cs and Form1.Designer.cs adds the description of Class Form1 in 2003 in Form1.cs. Description of Class Form1. This seems that the Partial type allows us to write a description of a class in different places, or even write two or more different files. Partial information is only useful to the compiler. The compiler sees the description of a class when compiling is "broken" (Partial), which will go to other places to collect other fragments of such classes, then put all the classes The fragmentation is combined into a complete class and compiles it. Therefore, Partial is not reflected in the compiled IL. As for the partial type, what is the meaning? We will discuss later. # 结 QQ: 14754875Email: tiy@citiz.netbbs: www.shixm.com/bbs