ONDotNet.com    
 Published on ONDotNet.com (http://www.ondotnet.com/)
 See this if you're having trouble printing code examples


O'Reilly Book Excerpts: VB.NET Core Classes in a Nutshell

An Introduction to the .NET FCL, Part 2

Related Reading

VB.NET Core Classes in a Nutshell
By Budi Kurniawan, Ted Neward

In part two of this book excerpt series on the .NET Framework Class Library from O'Reilly's VB.NET Core Classes in a Nutshell, get an introduction to the .NET Framework Class Library (FCL).


The .NET Framework Class Library

The .NET Framework includes the .NET Framework Class Library (FCL), a vast collection of thousands of types (that is, of classes, interfaces, structures, delegates, and enumerations) that aim at encapsulating the functionality of core system and application services in order to make application programming easier and faster. There are classes that you can use to manipulate the file system, access databases, serialize objects, and launch and synchronize multiple threads of execution, to name just a few.

To make working with these classes easy, classes with similar functionality are grouped together in namespaces. Therefore, there is a namespace containing types for drawing, a number of namespaces for .NET remoting, etc. In fact, the "intrinsic" functions of the Visual Basic language (such as InStr, Len, and UBound) are implemented as class methods in the Microsoft.VisualBasic namespace. In total, the .NET FCL places more than 80 namespaces at your disposal.

The .NET FCL includes classes with the following functionality:

Data type definition

Some members of the System namespace, such as the Object, String, Int32, and Single classes, form the data types used by Visual Basic .NET (as well as by other .NET languages that rely on the .NET Common Type System).

Exceptions

When an exception is generated, the CLR provides exception information to the Exception class (in the System namespace) or to one of the derived classes found throughout the .NET FCL.

Events and event handlers

The signature of event handlers is represented by the EventHandler delegate (in the System namespace) or one of its derived delegates. The event information passed to an event handler is represented by the EventArgs class (in the System namespace) or one of its derived classes.

Attributes

Attributes allow custom items of information about a program element to be stored with an assembly's metadata. Since this information becomes a permanent part of the program element's description, it is always available and can be used to modify the design time, compile time, or runtime behavior of a program element. Attributes are classes derived from the Attribute class (in the System namespace) or one of its derived classes found throughout the .NET FCL.

Collections and data structures

The .NET FCL features a number of general-purpose and more specialized collection classes. The general-purpose classes include the Array class (in the System namespace) and the ArrayList and CollectionBase classes (in the System.Collection namespace). Specialized classes include the Stack class, a last-in, first-out structure, the Queue class, a first-in, first-out structure, in the System.Collection namespace, and the ListDictionary class, a linked list dictionary class, in the System.Collection.Specialized namespace.

Control creation

The .NET FCL provides full support for custom Windows and web controls that integrate with design-time environments like Visual Studio through a number of classes, including the Container class in the System.ComponentModel namespace or the CollectionEditor class in the System.ComponentModel.Design namespace.

Configuration settings

Using the .NET FCL, you have easy access to application configuration information from configuration files using classes such as AppSettingsReader and DictionarySectionHandler in the System.Configuration namespace. You can also access registry data using the Registry, RegistryHive, and RegistryKey classes in the Microsoft.Win32 namespace. Finally, you can access ActiveDirectory information using the members of the System.DirectoryServices namespace.

Debugging, profiling, and diagnostics

The .NET FCL makes a large number of debugging, diagnostic, and informational classes available that can help in locating and fixing bugs, as well as in improving overall performance. These include the Debug, Debugger, EventLog, and PerformanceCounter classes in the System.Diagnostics namespace.

Drawing

Related Reading

VB.NET Core Classes in a Nutshell
By Budi Kurniawan, Ted Neward

The FCL provides a full set of graphics objects, such as the Color structure, the Brush class, the Font class, and the Graphics class in the System.Drawing namespace.

Input/output

The FCL allows you to read the standard input, standard output, and standard error streams, as well as to access the file system, through classes like File, FileInfo, StreamReader, and StreamWriter in the System.IO namespace.

Availability of metadata

Through the Type class in the System namespace and classes like Assembly, Module, EventInfo, MethodInfo, and ParameterInfo in the System.Reflection namespace, the .NET FCL provides support for reading metadata (the data that describes particular program elements) at any time.

Remote calls

Through classes such as ObjRef, RemotingConfiguration, and RemotingServices in the System.Runtime.Remoting namespace, the .NET FCL adds support for remoting (calls that cross process or machine boundaries).

String handling and manipulation

Interestingly, in the .NET Framework, strings are immutable. This means that simple operations such as string concatenation involve an enormous performance penalty. The StringBuilder class in the System.Text namespace makes it possible to perform string concatenation efficiently. The RegEx and Match classes in System.Text.RegularExpressions make it possible to perform regular expression searches on strings.

Control of threading

In previous versions of Visual Basic, threading was a factor that enormously impacted VB applications but over which the VB developer had no control. With classes like Thread, Mutex, and Monitor in the System.Threading namespace, the .NET FCL for the first time places threading under the direct control of the VB.NET developer.

In This Series

An Introduction to the .NET FCL, Part 5
In this final installment from VB.NET Core Classes in a Nutshell, learn how to approach the .NET FCL.

An Introduction to the .NET FCL, Part 4
In part four in this five part series on the .NET FCL from VB.NET Core Classes in a Nutshell, learn the types of a .NET namespace.

An Introduction to the .NET FCL, Part 3
In part three in this series of book excerpts on the .NET Framework Class Library from VB.NET Core Classes in a Nutshell, learn how to work with the .NET FCL.

An Introduction to the .NET FCL, Part 1
In part one of a five-part series of book excerpts from VB.NET Core Classes in a Nutshell, learn what it's like to develop without the .NET FCL library and its core classes.

Data access

The .NET FCL features a brand new data access technology, ADO.NET. It is represented by classes like the DataSet class in the System.Data namespace, the OleDbConnection, OleDbCommand, and OleDbDataReader classes in the System.Data.OleDb namespace, and the SqlConnection, SqlCommand, and SqlDataReader classes in the System.Data.SqlClient namespace.

Windows desktop applications

The forms and controls that made Visual Basic the premier Rapid Application Development package for Windows have their equivalent in the .NET FCL. These classes, such as the Form class, the Button class, and the TextBox class, are found in the System.Windows.Forms namespace.

Web application development

In addition to Windows controls, the .NET FCL features two sets of controls for web application development. HTML server controls execute on the server but otherwise correspond more or less directly to standard client-side HTML controls. They are found in the System.Web.UI.HTMLControls namespace. Web controls (also known as ASP controls) are server controls that abstract the functionality of controls in a web application. They are found in the System.Web.UI.WebControls namespace.

Web services

A web service is simply a function call over the Internet. The .NET FCL supports the development of web services through the types in the System.Web.Services namespace.

As you can see, the functionality offered by the .NET FCL is extensive--and in this overview of the .NET FCL, we've only emphasized the highlights.

In the next installment, learn to work with the .NET FCL.

VB.NET Core Classes in a  Nutshell

Related Reading

VB.NET Core Classes in a Nutshell
By Budi Kurniawan, Ted Neward

Copyright © 2009 O'Reilly Media, Inc.