< .Net Framework Class Library 6 | Main | .Net Framework Class Library 8 >


 

 

The .NET Framework Class Library 7

 

 

The topics in this part are listed below. The code snippets if any are based on the new C++ .NET syntaxes. The code snippets if any are based on the new C++ .NET syntaxes.

  1. The Collections Namespaces

  2. The Diagnostics Namespace

  3. The IO Namespace

 

 

 

 

 

 The Collections Namespaces

 

System::Collections is implemented in mscorlib.dll, while System::Collections::Specialized is implemented in system.dll, so if you want to use both, you’ll have to use two #using statements like the following:

#using <mscorlib.dll> // Can be excluded, available/included by default in VC++ 2005

#using <system.dll>

The following table lists the main classes that you’ll find in the System::Collections namespace.

 

Class

Description

ArrayList

A dynamically growable array

BitArray

A class that stores a number of Boolean values as the individual bits of an integer

Hashtable

A hash table that stores objects by hash key

Queue

A list where objects are added at one end and retrieved from the other end

SortedList

A linked list whose members are maintained in sorted order

Stack

A first-in, last-out stack

 

Table 8

 

The following table shows the main classes and structures that you’ll find in the System::Collections::Specialized namespace. The System::Collections::Specialized namespace contains specialized and strongly-typed collections; for example, a linked list dictionary, a bit vector, and collections that contain only strings.

 

Class

Description

BitVector32

A class that stores a number of Boolean values as the individual bits of a 32-bit integer.

ListDictionary

A dictionary implemented using a singly linked list.

NameValueCollection

A sorted collection of string keys and values.

StringCollection

An unsorted collection of strings.

StringDictionary

A hash table with the key strongly typed to be a string rather than an object.

StringEnumerator

An enumerator to work with StringCollection.

 

Table 9

 

The System::Collections namespace also defines a series of interfaces that are used to define the behavior of the collection classes. The collection classes themselves implement one or more of these interfaces, and you can use them as the basis for writing your own collection classes. The main interfaces are listed in the following table.

 

Interface

Description

ICollection

Defines the size, enumerator, and synchronization methods for all collections.

Icomparer

Defines a method for comparing two objects.

Idictionary

Implemented by collections that manage key/value pairs, such as Hashtable and ListDictionary.

IdictionaryEnumerator

Defines methods for enumerating over the items in a dictionary

Ienumerable

Defines the GetEnumerator method, which returns an Ienumerator; implemented by almost all collections.

Ienumerator

Defines the properties and methods of enumerators.

IhashCodeProvider

Implemented by classes that provide hash code values.

Ilist

Implemented by classes that define indexed collections of objects.

 

Table 10

 

In the .NET Framework version 2.0 there is new System::Collections::Generic namespace. The System::Collections::Generic namespace contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections. For more detail, check your .Net documentation for this thing.

 

The Diagnostics Namespace

 

System::Diagnostics provides a number of classes to:

  1. Trace program execution.

  2. Interact with the debugger.

  3. Use the system event log.

  4. Start system processes.

  5. Monitor system performance.

All the classes in System::Diagnostics are implemented in system.dll.

 

The IO Namespace

 

The System::IO namespace, defined in mscorlib.dll, provides the classes that implement the .NET input/output (I/O) functionality. The main classes in this namespace are described in the following table.

 

 

 

 

 

 

 

Class

Description

BinaryReader

Reads .NET primitive types from a byte stream.

BinaryWriter

Writes .NET primitive types to a byte stream.

Directory

Contains static methods for operating on directories.

DirectoryInfo

Represents a path to a directory, and contains methods for operating on the directory path.

File

Contains static methods for operating on files.

FileInfo

Represents a path to a file, and contains methods for operating on the file path.

FileStream

Reads and writes to files using streams.

FileSystemInfo

The base class for FileInfo and DirectoryInfo.

FileSystemWatcher

Watches for changes in the file system and fires events when changes occur.

IOException

The exception thrown when I/O errors occur.

MemoryStream

Reads and writes streams of bytes to and from memory.

Path

Represents directory strings in a platform-independent way.

Stream

The abstract base for the stream classes.

StreamReader

Reads Unicode characters from a byte stream.

StreamWriter

Writes Unicode characters to a byte stream.

StringReader

Reads Unicode characters from a string.

StringWriter

Writes Unicode characters to a string.

TextReader

The base class for StreamReader and StringReader.

TextWriter

The base class for StreamWriter and StringWriter.

 

Table 11

 

As with all the .NET Framework class library classes, these classes are language- independent. They can be used alongside or in place of the C++ stream classes.

 

Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7 | Part 8

 


 

< .Net Framework Class Library 6 | Main | .Net Framework Class Library 8 >