Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft C# Professional Projects - Premier Press.pdf
Скачиваний:
177
Добавлен:
24.05.2014
Размер:
14.65 Mб
Скачать

14

Part I

INTRODUCTION TO C#

 

 

 

Versioning

A well-known fact about the software industry is the regular change in the requirements of users. In such a dynamic scenario, new and improved versions of applications need to be developed. At numerous instances, when you upgrade an application, it may result in errors in the existing application. This can happen because the component that you upgrade might not be compatible with the earlier versions of the application. Problems in maintaining versions may also lead to problems in maintaining and debugging an application. An assembly includes features such as side-by-side and version dependency, which enable you to install multiple versions of the same assembly simultaneously.

NOTE

Every version of an assembly has the following four parts:

<Application name> <Major version>.<Minor version>.<Build>.<Revision>

Here, Major version is the main version number of the application, Minor version is a part of the version of the application, and Build and Revision numbers are generally based on the system date. If you specify “*” in place of Build and Revision, they are automatically generated based on the system date. Build is the number of days since 01/01/00, and Revision is the number of seconds since midnight, based on the system time.

For example, if the version name of an application is ABC 1.2.90.2670, then ABC is the application name. The number 1 refers to the Major version, 2 is the Minor version, and 90 is the Build. The Build value of 90 refers to the 90th day after 01/01/00, and 2670 is the number of seconds since the midnight of the 90th day after 01/01/00.

You looked at the components of the .NET Framework, class library being one of them. Now look at some of the .NET base classes contained in the class library.

An Overview of .NET Framework

Base Classes

As discussed earlier, .NET provides you with several predefined base classes in the

.NET class library. These classes contain methods that help you to create appli-

OVERVIEW OF THE .NET FRAMEWORK

Chapter 1

 

15

 

 

 

 

 

cations easily. Working with these classes is simple because of their user-friendly names.

The .NET class library consists of numerous base classes. However, in this chapter, you will be introduced to some of the most frequently used classes. You will learn more about these classes in the subsequent chapters.

Exceptions

Just as in C++, the .NET Framework is designed to handle exceptions. An exception is the erroneous execution of an application that results in an unpredicted output. When an exception is generated in a .NET application, an object of the Exception class, a .NET base class, is thrown. This object contains information about the error that is generated and the way that the .NET Framework handles the error. For example, the object might contain information about the message to be displayed when the compiler encounters an error or the details of the area within the code where the error was detected.

You can handle exceptions in the .NET Framework by using try{}, catch{}, and finally{} statements.These statements are similar to the statements that you use in C++ for handling exceptions.

Threads

A thread is single executable sequence of code. It is good practice to execute different sections of the application code, which are independent and parallel to each other. You can execute the code in sections by creating threads for each section and executing them simultaneously. For example, until an application prints data on a printer, you can use another thread to read from a file.This process is known as multithreading. To use the concept of multithreading in your application, you need to derive your class from the Thread class, which is another .NET base class.

Delegates

Delegate is yet another type of special class that consists only of method definitions. Delegates are objects that allow you to pass methods as parameters to another method. Just as with a class, you need to instantiate a delegate. The instance of the delegate is created from the Delegate class of the .NET base class library.