Information Technology Reference
In-Depth Information
A C# Program Is a Set of Type Declarations
If you were to broadly characterize the source code of C and C++ programs, you might say that
a C program is a set of functions and data types, and that a C++ program is a set of functions
and classes. A C# program, however, is a set of type declarations.
The source code of a C# program or DLL is a set of one or more type declarations.
-
For an executable, one of the types declared must be a class that includes a method
called Main .
For a DLL, none of the classes can declare a method called Main .
-
￿A namespace is a way of grouping a related set of type declarations and giving the group
a name. Since your program is a related set of type declarations, you will generally
declare your program inside a namespace you create.
For example, the following code shows a program that consists of three type declarations.
The three types are declared inside a new namespace called MyProgram .
namespace MyProgram // Create a new namespace.
{
DeclarationOfTypeA // Declare a type.
DeclarationOfTypeB // Declare a type.
class C // Declare a type.
{
static void Main()
{
...
}
}
}
Class libraries are sets of type declarations that are categorized into namespaces.
Namespaces will be covered in more detail in Chapter 10.
Search WWH ::




Custom Search