C# Program Structure

« Previous Tutorial Next Tutorial »

C# program structure comprises from these parts:

Comment may also be included, it is optional, since comments are ignored by the C# compiler.


Here is a simplest C# program given, for the understanding of general structure of a C# program:

/* C# Program Structure - Example Program */
using System;
namespace HelloWorldApp
   class HelloWorldClass
      static void Main(string[] args)
         /* this is my first program in C# language */
         Console.WriteLine("Hello World");

When the above code is compiled and executed, it will produce the following output:

Hello World

Here is the explanation of the above C# program:

Here are the steps to compile and execute the above C# program using Visual Studio .NET (VS.NET):

After processing the above given steps, your new project in the Solution Explorer is created. Now just write the above code in the Code Editor. After writing the code, to run your C# program, just press F5 key or click on the RUN button to execute the project. After performing this, a command prompt window will appears, containing the line, Hello World.

C# Online Test

« Previous Tutorial Next Tutorial »

© Copyright 2021. All Rights Reserved.