Home > Articles > Programming > Windows Programming

The .NET Framework Class Library: Types and Structures

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

  • Console class and applications

  • System namespace

  • Object class

  • Type class and Reflection namespace

  • Types

  • Conversions with the System.Convert Class

  • Reference types

  • Arrays

  • Collections

  • Strings

  • System.Text namespace

  • Formatting

In this chapter we will start our journey through the .NET Framework class library – a set of namespaces, classes, interfaces, and value types that are used in our .NET applications, components, and controls. Contrary to class libraries such as Microsoft Foundation Classes (MFC) or Borland Visual Class Library (VCL), the .NET Framework class library is language-independent. This means it can be used from any programming language, such as Visual Basic.NET, C#.NET, C++ with managed extensions, J#.NET, or any third-party language that conforms to the Common Language Specification (CLS).

The .NET Framework class library includes classes that support the following functions:

  • base and user-defined data types;

  • support for handling exceptions;

  • input/output and stream operations;

  • communications with the underlying system;

  • access to data;

  • ability to create Windows–based GUI applications;

  • ability to create web–client and server applications;

  • support for creating web services.

All classes implemented in the .NET class library are organized into namespaces. Each namespace contains classes and other types that are related to the specific task or set of tasks – input/output operations, web applications creation, working with data and XML, and so on. Table 3.1 shows the most important namespaces in the .NET class library.

Table 3.1. The main namespaces in the .NET class library




Contains fundamental classes and base classes that define common value and reference data types, events and event handlers, interfaces, processing exceptions, data conversion, mathematics, as well as garbage collection and application environment management. Some of the classes defined in the namespace are covered in this chapter and also in Chapters 4 and 5.


Provides classes that support asynchronous and synchronous reading from and writing to data streams and files. Contains classes like FileStream, MemoryStream, Path, and Directory. We will learn about this namespace and its classes in the next chapter.


Contains interfaces and classes that define various collections of objects, such as lists, arrays, hash tables, stacks, queues, and dictionaries. The classes defined in this namespace are covered in this chapter.


Provides classes and interfaces that support multithreaded programming. Contains classes such as Thread, ThreadPool, Mutex, and AutoResetEvent.


Contains classes that provide dynamic binding and a managed view of loaded types, methods, and fields. Contains classes such as Assembly, Module, and MethodInfo.


Implements a security system, including base classes for permissions. Includes classes of the likes of SecurityManager, PermissionSet, and CodeAccessPermission.


Provides support for network programming. Includes, for example, the classes HttpWebRequest, IPAddress, Dns, and Connection. We will learn about this namespace and its classes in the next chapter.


Contains classes that implement ADO.NET. Child namespaces include OLEDB, and SqlClient. This namespace will be discussed in Chapter 12.


The System.XML namespace provides support for processing XML documents. Child namespaces include Schema, XSL, and XPath. We will discuss this namespace and its secondary namespaces in Chapter 14.


Serves as a base for ASP.NET applications. Contains such classes as HTTPRequest, HTTPResponse, and HTTPServerUtility. Child namespaces include Caching, Configuration, Security, and UI. We will discuss this namespace and its secondary namespaces in Chapters 6 and 7.


Enables us to build and use web services. Secondary namespaces include Description, Discovery, and Protocols. We will discuss this namespace and its secondary namespaces in Chapter 15.


Contains classes used to create form-based Windows applications. We will discuss this namespace in Chapters 8, 9, and 10


Provides access to the graphics functionality of GDI+. Contains secondary namespaces such as Design, Drawing2D, Imaging, Printing, and Text. We will discuss this namespace and its secondary namespaces in Chapter 11.

System.Globalization System.Resources

Contains classes that define culture-related information – language, country/region, calendar, and so on. Classes from the Resources namespace are used to create localized Windows and web applications.

After this brief overview of most of the chapters in the book, we are ready to start our journey through the .NET Framework class library. Main namespaces are shown in Figure 3.1. Our first stop is a little bit unusual – instead of covering the Object class – that is, the ultimate ancestor for all of the classes in the .NET Framework class library – we will discuss the Console class. The following section will explain why we do this.

03fig01.gifFigure 3.1. Main namespaces in the .NET framework class library

3.1 Console class and applications

Using the System.Console class, we can implement the simplest .NET application – a console application that runs in a system-supplied window and does not require a graphical user interface. Since in this and several other chapters of this book we will use the console applications heavily, we will start this chapter with an overview of the Console class.

The Console class represents the standard input, output, and error streams. Applications built on this class can read characters from the standard input stream and write characters to the standard output stream. Errors are written to the standard error output stream. These three streams are automatically associated with the console on which the application starts and we can obtain them via the In, Out, and Error properties of the Console class. By default, the standard input stream is a System.IO. TextReader object, the output and output error streams are System.IO.TextWriter objects. If we need it, we can associate input and output streams with different streams – file streams, network streams, memory streams, and so on.

In Visual Basic.NET, we create a console application by creating a new module that contains one subroutine called Main – this is the entry point into our console application (see Figure 3.2):

03fig02.gifFigure 3.2. Console application in action

' .NET Console Application 
Imports System 
Module Cons 

 Sub Main() 

    Console.WriteLine(".NET Console application") 

 End Sub 

End Module 

The Read and ReadLine methods allow us to read a character or new line character from the standard input, while Write and WriteLine perform the output.

The SetIn, SetOut, and SetError methods allows us to specify different input, output, and error output streams. These methods take a parameter of TextWriter type that specifies the output stream.

Now we are ready to start to learn about the Microsoft .NET class library. We will start with an overview of the System namespace.

  • + Share This
  • 🔖 Save To Your Account