C# Program Structure

An executable C# program may contain several coding blocks are given as 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
  • 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.
  • An interface is similar to a class but contains only abstract members. Interface section is used when we want to implement the concept of multiple inheritances.
  • C# program-structure

  • 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.
  • 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. On the end of Main(), the program terminates and control passes back to the operating system.