String Enumerations

 

Where to Place the Declarations

The new Microsoft MSBuild formats for all project files will be extended to include all the programming languages in the Visual Studio suite in the coming years . The most notable change in the project file formats is the decision to split the declarations for a given project into two groups. To accommodate this split, the new keyword partial is used, as shown in line CP010 below.

Some of the declarations (the computer-generated declarations that result from the controls and forms that the programmer chooses to include in the project) are placed in the *.Designer.cs window template file. As a result, this file will be rarely visited by the programmer (only the IDE writes to this file, except in rare circumstances).

Those additional declarations, which are the responsibility of the individual programmer, must be placed in one small area in the *.cs source code file. For example, in project CodePlacement, Form1.cs, all the programmer s declarations are shown in lines CP011-CP013:

 CP001:        #region Using directives CP002-007:    [6 lines of 'using' statements] CP008:        #endregion CP009:        namespace CodePlacement CP010:        partial class Form 1 : Form               { CP011:          public int intNumber = 6; CP012:          int intGlobalNumber = 77; CP013:          public int[] intArray = new int[] {1, 22, 88}; CP014:          public Form1()                 {                   InitializeComponent();                 } //-----------------------------------------------------------------------------------------// CP101:          private void button1_Click(object sender, EventArgs e)                 etc. 

The statements in public Form1() are all executable statements. No declarations will be tolerated here. This is where the programmer can place those executable statements that are commonly placed in the Load procedure (private void FormX_Load()) since public Form1() is executed before the window is opened (and never executed again).

 


Unlocking Microsoft C# V 2.0 Programming Secrets
Unlocking Microsoft C# V 2.0 Programming Secrets (Wordware Applications Library)
ISBN: 1556220979
EAN: 2147483647
Year: 2005
Pages: 129

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net