Jon Jagger
Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specificationpreviousnextprevious at this levelnext at this level 10 Basic conceptsprevious at this levelnext at this level 10.1 Application startup Paragraph 11 Application startup occurs when the execution environment calls a designated method, which is referred to as the application's entry point. 2 This entry point method is always named Main, and shall have one of the following signatures:
static void Main() {...}  
static void Main(string[] args) {...}  
static int Main() {...}  
static int Main(string[] args) {...}  
Paragraph 21 As shown, the entry point may optionally return an int value. 2 This return value is used in application termination (§10.2). Paragraph 31 The entry point may optionally have one formal parameter, and this formal parameter may have any name. 2 If such a parameter is declared, it must obey the following constraints: Paragraph 41 Since C# supports method overloading, a class or struct may contain multiple definitions of some method, provided each has a different signature. 2 However, within a single program, no class or struct shall contain more than one method called Main whose definition qualifies it to be used as an application entry point. 3 Other overloaded versions of Main are permitted, however, provided they have more than one parameter, or their only parameter is other than type string[]. Paragraph 51 An application can be made up of multiple classes or structs. 2 It is possible for more than one of these classes or structs to contain a method called Main whose definition qualifies it to be used as an application entry point. 3 In such cases, one of these Main methods must be chosen as the entry point so that application startup can occur. 4 This choice of an entry point is beyond the scope of this specification-no mechanism for specifying or determining an entry point is provided. Paragraph 61 In C#, every method must be defined as a member of a class or struct. 2 Ordinarily, the declared accessibility (§10.5.1) of a method is determined by the access modifiers (§17.2.3) specified in its declaration, and similarly the declared accessibility of a type is determined by the access modifiers specified in its declaration. 3 In order for a given method of a given type to be callable, both the type and the member must be accessible. 4 However, the application entry point is a special case. 5 Specifically, the execution environment can access the application's entry point regardless of its declared accessibility and regardless of the declared accessibility of its enclosing type declarations. Paragraph 71 In all other respects, entry point methods behave like those that are not entry points.
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS