The next layer up in the framework provides the services and object models for data, input/output, security, and so forth. It is called the .NET Class Framework, sometimes referred to as the .NET base classes.
The .NET Class Framework contains literally thousands of classes and interfaces. Here are just some of the functions of various libraries in the .NET Class Framework:
Data access and manipulation
Creation and management of threads of execution
Interfaces from .NET to the outside world - Windows Forms, Web Forms, Web Services, and console applications
Definition, management, and enforcement of application security
Encryption, disk file I/O, network I/O, serialization of objects, and other system-level functions
Application configuration
Working with directory services, event logs, performance counters, message queues, and timers
Sending and receiving data with a variety of network protocols
Accessing metadata information stored in assemblies
Much of the functionality that a programmer might think of as being part of a language has been moved to the base classes. For example, the old VB6 keyword Sqr for extracting a square root is no longer available in .NET versions of Visual Basic. It has been replaced by the System.Math.Sqrt() method in the framework classes.
It’s important to emphasize that all languages based on the .NET Framework have these framework classes available. That means that COBOL, for example, can use the same function mentioned above to get a square root. This makes such base functionality widely available and highly consistent across languages. All calls to Sqrt look essentially the same (allowing for syntactical differences among languages) and access the same underlying code. Here are examples in VB.NET and C#:
' Example using Sqrt in Visual Basic .NET Dim dblNumber As Double = 200 Dim dblSquareRoot As Double dblSquareRoot = System.Math.Sqrt(dblNumber) Label1.Text = dblSquareRoot.ToString ' Same example in C# Double dblNumber = 200; Double dblSquareRoot = System.Math.Sqrt(dblNumber); dblSquareRoot = System.Math.Sqrt(dblNumber); label1.Text = dblSquareRoot.ToString;
Notice that the line using the Sqrt() function is exactly the same in both languages.
Tip | A programming shop can create its own classes for core functionality, such as globally available, already compiled functions. This custom functionality can then be referenced in code the same way as built-in .NET functionality. |
Much of the functionality in the base framework classes resides in a vast namespace called System. The System.Math.Sqrt() method was just mentioned. The System namespace contains dozens of such subcategories. The following table describes a few of the important ones, many of which you will be using in various parts of this book:
Namespace | What It Contains | Example Classes and Subnamespaces |
---|---|---|
System.Collections | Creation and management of various types of collections | Arraylist, Hashtable, SortedList |
System.Data | Classes and types related to basic database management (see Chapter 10 for details) | DataSet, DataTable, DataColumn |
System.Diagnostics | Classes to debug an application and to trace the execution of code | Debug, Trace |
System.IO | Types that allow reading and writing to and from files and other data streams | File, FileStream, Path, StreamReader, StreamWriter |
System.Math | Members to calculate common mathematical quantities, such as trigonometric and logarithmic functions | Sqrt (square root), Cos (cosine), Log (logarithm), Min (minimum) |
System.Reflection | Capability to inspect metadata | Assembly, Module |
System.Security | Types that enable security capabilities (see Chapter 12 for details) | Cryptography, Permissions, Policy |