Program Structure

A C# application is a collection of compilation units (files) containing classes that embody functionality that can be executed. When compiled, it can be targeted as a .Net shared library or a .Net application.

The above statement covers nearly every aspect of the C# language. Here, we simply want to give a high-level, quick start perspective.

Firstly, a compilation unit is a file ending with the .cs extension.

Secondly, a module is a compiled file. It’s actually a DLL without what is termed a manifest, so the CLR (Common Language Runtime) cannot load the file. A .cs file can be compiled into a module using the following command

csc /t:module <.cs input-file>

And thirdly, an assembly is a group of compiled files (resources and type definitions) packaged up either as a shared library file or as an executable and containing the metadata. A .cs file can be compiled into a module using the following command

csc /out:<multifile-library-name>.dll /t:library [/addmodule:<module-name>] <.cs input-file>

So a .Net application can be comprised of 1 or more files.

A single file application is composed as follows (target file could be a DLL)

 

A multifile application is composed as follows (target file could be a DLL)

C# .Net application must have one and only one Main() method defined

A class is an optional construct that is used to attribute behaviour to a compilation unit

We will address these two topics in later sections of the course.