Introduction to ASP.NET - The .NET Framework Class Library (FCL)
(Page 2 of 10 )
The FCL is a set of reusable object-oriented classes that provide basic platform functionality, from the data access classes of ADO.NET, to filesystem utility classes (including file, directory, and stream classes), to networking classes that allow easy implementation of DNS resolution, WHOIS lookups, and other network-related functionality. Developers can use the base classes directly or derive from these classes to provide customized functionality.
The FCL also contains all classes that make up ASP.NET. These include classes that implement all of the functionality of the ASP intrinsic objects, as well as classes that provide additional functionality, from a rich engine for caching output and data to the ASP.NET Server Control model. This functionality brings to ASP.NET the simplicity of control-based development that has long been available to Visual Basic developers.
In addition to classes that support Web application development, the FCL provides classes for developing console applications, Windows applications, and Windows NT or Windows 2000 Services.
The Common Type System (CTS) The CTS describes the set of types that are supported by the CLR. This includes both value types, which include primitive data types such as Byte, Int16, Double, and Boolean, and reference types, which include arrays, classes, and the Object and String types.
Value types are types that store their values directly in memory and are accessed directly by name, as shown in the following code fragment:
'VB.NET
Dim myFloat As Single
myFloat = 3.1415
// C#
float myFloat;
myFloat = 3.1415;
In addition to these built-in data types, value types also include user-defined value types (types derived from the System.ValueType class) as well as enumerations.
Reference types are types that store a reference to the location of their values, rather than storing the value directly. Frequently, the value is stored as part of a defined class and is referenced through a class member on an instance of the class, as shown here:
'VB.NET
'Define class
Class myFloatClass
Public myFloat As Single
End Class
'Create class instance and assign value
Dim myInstance As New myFloatClass()
myInstance.myFloat = 3.1415
// C#
// Define class
class myFloatClass
{
float myFloat;
}
// Create class instance and assign value
myFloatClass myInstance = new myFloatClass();
myFloatClass.myFloat = 3.1415;
Individual language compilers may implement types using their own terminology. For example, while the .NET representation of a 32-bit integer is referred to as Int32, in Visual Basic .NET it is referred to as Integer and in C# as int. Internally, however, both Visual Basic’s Integer and C#’s int are implemented as the .NET Int32 type.
Boxing and unboxing Converting to and from value and reference types is accomplished through a process called boxing and unboxing. Boxing refers to the implicit conversion of a value type, such as a C# int, to a reference type (usually Object). For this conversion to take place, an instance of type Object is created and the value type’s value and type is copied into it—in this case, int. Unboxing refers to the explicit conversion of an Object type into a specific value type. The code example shown here demonstrates boxing and unboxing:
// C#
int myInt = 123; // declare an int and set its value to 123
object myObj = myInt; // value of myInt is boxed into myObject
int myOtherInt = (int)myObject; // unbox myObject into myOtherInt
 | If you've enjoyed what you've seen here, or to get more information, click on the "Buy the book!" graphic. Pick up a copy today!
Visit the O'Reilly Network http://www.oreillynet.com for more online content. |
Next: The Common Language Infrastructure (CLI) >>
More ASP.NET Articles
More By O'Reilly Media