C# Program Structure

An executable C# program may contain several coding blocks given below in Figure:

The Documentation section consists of a set of comments giving the name of the program. Comments must include:

  • Why and what of classes
  • How of algorithms

C# program-structure

i. The Directive section will include al those namespaces that contain classes required by the application. The directive section tells the compiler to look in the namespace specified for these unresolved classes.

ii. An interface is similar to a class but contains only abstract members. The interface section is used when we want to implement the concept of multiple inheritances.

iii. A C# program may contain multiple class definitions. Classes are the primary and essential elements of a C# program. These classes are used to map the objects of real-world problems.

iv. Every C# application program requires a Main() method as it is the starting point, the class containing the Main() is the essential part of the program. The Main() method creates objects of various classes and establishes communication between them. At the end of Main(), the program terminates and control passes back to the operating system.