December 2001
Intermediate to advanced
416 pages
8h 16m
English
The traditional first program in a new language is one that prints Hello, World! on the user's console. In C# this program is implemented as follows:
// our first C# program
using System;
class Hello
{
public static void Main()
{
Console.WriteLine( "Hello, World!" );
}
}
When compiled and executed, this code generates the canonical
Hello, World!
Our program consists of four elements: (1) a comment, introduced by the double slash (//), (2) a using directive, (3) a class definition, and (4) a class member function (alternatively called a class method) named Main().
A C# program begins execution in the class member function Main(). This is called the program entry point. Main() must be defined as static. In our example, ...
Read now
Unlock full access