| |
|
What is the use of the main() function in C#?
Every executable C# application must contain a class defining a Main() method that signifies the entry point
of the application. Note that the Main() method is of the access type public by nature. Moreover, it is also
static. See example below:
C# Example
using System;
class Question
{
public static int Main(string[] args)
{
Console.Writeline("Another Question");
Console.Readline();
return 0;
}
}
A public member is accessible from other types. The main() method is set as static so that
it may be invoked at class level itself, without the need of creating an instance of it. The single
parameter is an array of strings. that may contain any number of incoming command line arguments.
Protected Internal
Array
Sort Array
Throw
Multiple Catch
Polymorphism
Inheritance
Session Viewstate
Autogenerate
ReadOnly
Sealed Class
Sealed Method
Multiple Interfaces
Overloading
Overloaded Constructors
Generics
Main
Case Sensitive
Console
Specifier
Return Type
SetCommandLineArgs
System Environment
New
Default Values of Types
Compiler Error
Constant Variable
Const
Const - ReadOnly
Parameter Modifier
Out Ref
Interface
Interface Reference, is, as
System.Collection
More Interview Questions...
| |