|
Chapter 3: Basic concepts
3. Basic concepts3.1 Program StartupProgram startup occurs when the execution environment calls a designated method, which is referred to as the program’s entry point. This entry point method is always namedMain, and can have one of the following signatures:
static void Main() {…}
static void Main(string[] args) {…}
static int Main() {…}
static int Main(string[] args) {…}
As shown, the entry point may optionally return an The entry point may optionally have one formal parameter, and this formal parameter may have any name. If such a parameter is declared, it must obey the following constraints:
Since C# supports method overloading, a class or struct may contain multiple definitions of some method, provided each has a different signature. However, within a single program, no class or struct shall contain more than one method called
A program can be made up of multiple classes or structs, two or more of which contain a method called In C#, every method must be defined as a member of a class or struct. Ordinarily, the declared accessibility (section 3.5.1) of a method is determined by the access modifiers (section 10.2.3) specified in its declaration, and similarly the declared accessibility of a type is determined by the access modifiers specified in its declaration. In order for a given method of a given type to be callable, both the type and the member must be accessible. However, the program entry point is a special case. Specifically, the execution environment can access the program’s entry point regardless of its declared accessibility and regardless of the declared accessibility of its enclosing type declarations. In all other respects, entry point methods behave like those that are not entry points.
Last Updated: Saturday, July 7, 2001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||