1csharp Program Structure
1csharp Program Structure
Before we study basic building blocks of the C# prog ramming lang uag e, let us look at a bare minimum C#
prog ram structure so that we can take it as a reference in upcoming chapters.
When the above code is compiled and executed, it produces the following result:
Hello World
WriteLine is a method of the Console class defined in the System namespace. T his statement causes the
messag e "Hello, World!" to be displayed on the screen.
T he last line Console.ReadKey(); is for the VS.NET Users. T his makes the prog ram wait for a key
press and it prevents the screen from running and closing quickly when the prog ram is launched from
Visual Studio .NET .
It's worth to note the following points:
C# is case sensitive.
All statements and expression must end with a semicolon (;).
T he prog ram execution starts at the Main method.
Unlike Java, file name could be different from the class name.