This section provides a tutorial example on how to write the first C# program to print out 'Hello world!' on the screen, compile it and run it on with .NET Framework 1.0.
Let's follow the tradition of the programming language world and write our
first C# program to print out "Hello world!" on the screen.
You can use notepad to write the following code and save it as c:\home\herong\csharp\hello.cs:
class Hello {
public static void Main() {
System.Console.WriteLine("Hello world!");
}
}
To compile and run the program, open command window and issue the following commands:
C:\herong\csharp>csc hello.cs
Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.
>hello
Hello world!
Congratulation, you have successfully created, compiled, and executed your first C# program!