Reply to comment

C# Programs

  • A C# program consists of one or more files
  • Each file contains zero or more namespaces
  • Each namespace can contain:
    • Classes
    • Interfaces
    • Structs
    • Enums
    • Delegates
    • Nested namespaces

Compiling a program from the command line

  • Open a Visual Studio Command Prompt, or,
  • Open a command prompt and type vsvars32.bat (to put the Visual C# toolset on the path)
  • type csc prog.cs

The Main method:

static void Main( )
static int Main( )
static void Main( string[] args )
static int Main( string[] args )
{
if( args.Length == 0 ) {
}
}

- The Main method is declared inside a class or a struct
- Main must be static
- Main should not be public
- The containing class or struct doesn't need to be static
- args[0] is the first parameter, not the program name.

- A program can have more than one class containing a Main method. However, only one can be chosen as the entry point ( /main compiler option)

long aliases Int64

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options