Chapter 5: C and the Base Classes

 
Chapter 5 - C# and the Base Classes
bySimon Robinsonet al.
Wrox Press 2002
  

Overview

In this chapter, we are going to take a closer look at the base classes and how they interact with the C# language to give you support for writing code in a number of areas. In particular, we are going to examine the following topics:

  • Strings and regular expressions

  • Groups of objects, including array lists, collections, and dictionaries

  • Custom attributes and how to use them

  • Reflection

  • Threading

We will also examine System.Object , the class from which everything else is derived, in more detail.

These look like a somewhat miscellaneous range of subjects to tackle in one chapter, but there is a good reason for it. You see, we have made it clear right from the start that it is not possible to view the C# language in isolation. The language interacts with both the .NET Framework and the associated class library, the .NET base classes, in a very fundamental way. We have seen numerous examples of this as we have explored C# in the last few chapters. For example, all of the C# keywords that represent data types, such as int , long , and string , are mapped by the compiler directly onto corresponding base classes (in these cases, System.Int32 , System.Int64, and System.String ). Another example is that in the case of exceptions, the throw and catch statements require that the exception object is inherited from System.Exception .

The interaction between C# and the base classes has made it impossible for us to introduce you to the C# language without covering a fair number of classes in the .NET base class library in the process. However, up to now the emphasis has largely been on features of C#, in which the language syntax is the predominant issue, and base classes have been seen as helpers. In this chapter, we will reverse that, and look at a number of features that are available in C# that are sufficiently fundamental to be considered as a part of the language, but which are explicitly implemented mainly through the use of certain base classes rather than through the C# language syntax. At the end of this chapter, we will have a sufficient grounding in C# so that we will be ready to look in detail at applications, and how the language is applied in a number of specific areas the subject of the rest of the book.

  


Professional C#. 2nd Edition
Performance Consulting: A Practical Guide for HR and Learning Professionals
ISBN: 1576754359
EAN: 2147483647
Year: 2002
Pages: 244

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net