Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# ПІДРУЧНИКИ / c# / Manning - Windows.forms.programming.with.c#.pdf
Скачиваний:
108
Добавлен:
12.02.2016
Размер:
14.98 Mб
Скачать

A.1 C# PROGRAMS

A C# program consists of a collection of source files where each source file is an ordered sequence of Unicode characters. Typically, each source file corresponds to a single file in the file system. A program is compiled into a set of computer instructions known as an assembly. The .NET Framework interprets or otherwise executes an assembly to perform the instructions given in the original program.

A.1.1 ASSEMBLIES

Assemblies are containers for types, and are used to package and deploy compiled C# programs. An assembly may contain one or more types, the instructions to implement these types, and references to other assemblies. While not strictly required, an assembly is normally a single file in a file system. For example, the System.Windows.Forms.dll file is the assembly for the System.Windows.Forms namespace.

There are two kinds of assemblies: Applications and libraries. An application is an assembly that has a main entry point and usually has a “.exe” extension. Applications are used to perform a specific task or tasks on behalf of a computer user. The main entry point of an application is the initial instruction to execute in the program.

A library is an assembly that does not have a main entry point and usually has a “.dll” extension. Libraries are used to encapsulate one or more types for use when building other assemblies.

A.1.2 NAMESPACES

Logically, the source files in a C# program contain a collection of namespaces. Each namespace defines a scope, or declaration space, in which a set of zero or more type declarations and zero or more nested namespaces are defined. The possible type declarations are classes, structures, interfaces, enumerations, and delegates. Each type declaration is assigned a name that is unique within its declaration space, in this case within the defined namespace. It is an error for two type declarations to have the same name within the same namespace.

All type declarations are assigned to a namespace. If a specific namespace is not specified, then the type is assigned to the default namespace, also called the global namespace.

A namespace is declared in the following manner:1

namespace <name>

{

<nested-namespaces>opt

<type-declarations>

}

1 We use the convention here and in other syntax examples where items in angle brackets < > are filledin by the programmer. An optional item will include an “opt” subscript following the item.

638

APPENDIX A C# PRIMER

Соседние файлы в папке c#