| |
||||||||||||||||||||||
One of the rich experiences in working with .NET is a huge collection of Base Class Libraries. The .Net Framework Class Library is a library of classes, interfaces, and value types that are included in the Microsoft.NET Framework SDK. The Library provides access to system functionality and is designed to be the foundation on which .NET Framework application, components, and controls are built. The library is, of course, organized around a namespace hierarchy. Classes include functionality for file I/O, printing, font management, security, data access, threading, web service, string manipulations, messaging, and the list goes on and on. The Framework class library, is written in managed code that runs on top of the .NET common Language Runtime. It reaps all of the benefits of any other piece of managed code, such as:
Sealed: Specifies that you cannot inherit from this class. A good example of sealed class in the Framework class Library is the String class. In Visual Basic .NET, you can create your own sealed classes by using the NotInheritable keyword. Implements: Specifies the interfaces implemented by a particular class. For instance, the Array class implements the Ilist interface, imbuing Arrays with the capability to add and retrieve the index of a member. Abstract: Indicates that the class cannot be directly instantiated. They typically exist as a means of organizing lower-level derived classes, or as a convenient virtual class that is used solely as s template for other classes, these include the XMLWriter class in the System.XML namespace. and the image class in the system.Drawing namespace. Inherits: Identifies the base class that the current class inherits from. As an example, the colorDialog class inherits from the commonDialog class- an acknowledgment of the fact that it is a type of common dialog. Exported/not exported: Indicates whether a class is visible outside of its defining assembly. Exported classes are those visible outside of the assembly in which they are defined. Classes Have Members Classes contain the following members -- the properties, methods, fields, events, and constructors that make up a class. Members can be of two basic types -- static or instance. Static members (also known as shared members) are shared across all instances of a class and do not require you to work with a specific instance of the class. To use a static member, you simply refer to the member using the class name as if it were the name of the object. For example, the Pow method of the System.Math class is a static member. Using this method, you can raise a number to a power. answer = Math.Pow(5, 3) In contrast to static members, instance members work on a specific instance of an object, which means that you must first create the object instance before you can use an instance member. For example, you can use the NextDouble method of the System.Random class, an instance member, to return a random number. The following code sets the dblRandom variable to a random number using a System.Random object: Dim dblRandom As Double Dim rnd As Random = New Random dblRandom = rnd.NextDouble VB.NET Functions versus System Class Members The VB.NET language has a long and sorted history. While Microsoft has removed some legacy functionality, there remains a number of VB.NET language features that overlap the functionality of the System classes. When given the choice, it's almost always a better idea to use the System classes rather than legacy VB.NET functionality. Using the System classes makes code more portable to other languages and better suited for future versions of VB.NET, in which Microsoft may remove some older legacy functionality. Structures: Structures are the .NET version of user-defined types from prior version of Visual Basic. User defined types (or UDT). Type …End type syntax is no longer supported. It has been replaced with structure…End structure Structures in .NET behave a lot like classes. They support most of the constructs of a class including properties, methods, and events. Some of the key similarities and differences between classes and structures are:
In the class library, structures are used to represent values such as integers(Int16, Int32, Int64). In fact, the actual structure object inherits directly from the class ValueType in the root system namespace. Instantiating objects from the class Library The use of base classes as a block box is probably the primary path for most developers. In this mode, your code will be treating the class library as a simple API to get at core functions on your particular operating system. Using the class library classes in this manner does not represent a departure from the programming model that Visual Basic developers are used to. As an example, if you have programmed Visual Basic applications that have made use of the Ado library, you probably did the following: 1: You set a reference to the code library through the VB IDE 2: You Dim’d a Container for one of the ADO object 3: After you had a container, you instantiated a version of an ADO object into it. 4: After that, you simply invoked its methods and properties as needed With VB.NET, your consumption of Framework classes will follow the exact same pattern. Inheriting from the Framework Class Library With the exception of those classes marked as sealed, you are free to build your own classes on any of the base classes, in the class library using the inheritance model in .NET Exception Handling Exception Handling is the process of managing errors that may be encountered during the execution of your code. The .NET runtime, and the .NET language, supports the concept of Structured Execution Handling (SHE). These exception handlers follow a standard format that defines a try block, catch block, and a Finally block. Writing an exception handler requires you to place the code that will possibly generate an error into Try block. In the catch block, you place your code that deals with error. The Finally block is where you place operations that should be preformed regardless of whether an error was raised or not. Sub DoCalc(Byval n1 as integer, n2 as integer) as integer Try DoCalc= n1/n2 Catch appError as Exception Msgbox(“Error: “ & appError.Message) Finally Beep() End Try End Sub Form Class In the .NET Framework, the form class is the primary object that you use to create and manipulate forms. It is a representation of any type of window that you might need to display in an application, from dialog boxes to resizable windows to MDI windows. You interact with the Form class as you do any other class in the .NET Framework. Core Types This namespace is the heart of the FCL and contains classes, interfaces, and attributes that all other types depend on. The root of the FCL is the type Object, from which all other .NET types derive. Other fundamental types are ValueType, Enum, Convert , Exception, and the boxed versions of the predefined value types. The interfaces that are used throughout the FCL are items such as, ICloneable, IComparable, IFormattable, and IConvertible. Extended types such as DateTime, TimeSpan, and DBNull are also available. Other classes include support for delegates, basic math operations, attributes, and exception handling. Text The FCL provides rich support for text. Important types include a String class for handling immutable strings, a StringBuilder class that provides string-handling operations with support for locale-aware comparison operations and multiple string-encoding formats, (such as ASCII, Unicode, UTF-7, and UTF-8), and a set of classes that provide regular expression support Collections The FCL provides a set of general-purpose data structures such as Array, ArrayList, Hashtable, Queue, Stack, BitArray, and more. Standardized design patterns using common base types and public interfaces allow consistent handling of collections throughout the FCL for both predefined and user-defined collection types Streams and I/O The FCL provides good support for accessing the standard input, output, and error streams. Classes are also provided for performing binary and text file I/O, registering for notification of filesystem events, and accessing a secure user-specific storage area known as Isolated Storage. Networking The FCL provides a layered set of classes for communicating over the network using different levels of abstraction, including raw socket access; TCP, UDP, and HTTP protocol support; a high-level, request/response mechanism based on URIs and streams; and pluggable protocol handlers Threading The FCL provides rich support for building multithreaded applications, including thread and thread pool management; thread-synchronization mechanisms such as monitors, mutexes, events, reader/writer locks, etc.; and access to such underlying platform features such as I/O completion ports and system timers Security The FCL provides classes for manipulating all elements of the .NET runtime's Code Access Security model, including security policies, security principals, permission sets, and evidence. These classes also support cryptographic algorithms such as DES, 3DES, RC2, RSA, DSig, MD5, SHA1, and Base64 encoding for stream transformations. Reflection and Metadata The .NET runtime depends heavily on the existence of metadata and the ability to inspect and manipulate it dynamically. The FCL exposes this via a set of abstract classes that mirror the significant elements of an application (assemblies, modules, types, and members) and provide support for creating instances of FCL types and new types on the fly Assemblies The FCL provides attributes that tag the metadata on an assembly with information such as target OS and processor, assembly version, and other information. The FCL also provides classes to manipulate assemblies, modules, and assembly strong names. Serialization The FCL includes support for serializing arbitrary object graphs to and from a stream. This serialization can store and transmit complex data structures via files or the network. The default serializers provide binary and XML-based formatting but can be extended with user-defined formatters. Remoting Remoting is the cornerstone of a distributed application. The FCL provides excellent support for making and receiving remote method calls. Calls may be synchronous or asynchronous; support request/response or one-way modes; can be delivered over multiple transports (such as TCP, HTTP, and SMTP); and can be serialized in multiple formats (such as SOAP and binary). The remoting infrastructure supports multiple activation models, lease-based object lifetimes, distributed object identity, object marshaling by reference and by value, and message interception. These types can be extended with user-defined channels, serializers, proxies, and call context. Web Services Logically, web services are simply an instance of remoting. In reality, the FCL support for web services is considered part of ASP.NET and is largely separate from the CLR remoting infrastructure. Classes and attributes exist for describing and publishing web services, discovering which web services are exposed at a particular endpoint (URI), and invoking a web service method. Data Access The FCL includes a set of classes that access data sources and manage complex data sets. Known as ADO.NET, these classes are the managed replacement for ADO under Win32. ADO.NET supports both connected and disconnected operations, multiple data providers (including nonrelational data sources), and serialization to and from XML. XML The FCL provides broad support for XML 1.0, XML schemas, and XML namespaces. These include: two separate XML parsing models, (a DOM2-based model and a pull-mode variant of SAX2) and implementations of XSL/T, XPath, and SOAP 1.1. Graphics The FCL includes classes to support working with graphic images. Known as GDI+, these classes are the managed equivalent of GDI under Win32 and include support for brushes, fonts, bitmaps, text rendering, drawing primitives, image conversions, and print-preview capabilities. Rich Client Applications The FCL includes support for creating classic GUI applications. This support is called Windows Forms and consists of a forms package, a predefined set of GUI components, and a component model suited to RAD designer tools. These classes provide varying degrees of abstraction from low-level, message-loop handler classes to high-level layout managers and visual inheritance. Web-Based Applications The FCL includes support for creating web-based applications. This support is called Web Forms and consists of a server-side forms package that generates HTML UI, a predefined set of HTML-based GUI widgets, and a component model suited to RAD designer tools. The FCL also includes a set of classes that manage session state, security, caching, debugging, tracing, localization, configuration, and deployment for web-based applications. Finally, the FCL includes the classes and attributes that produce and consume web services. Collectively, these capabilities are known as ASP.NET and are a complete replacement for ASP under Win32. Globalization The FCL provides classes that aid globalization by supporting code-page conversions, locale-aware string operations, date/time conversions, and the use of resource files to centralize localization work. Configuration The FCL provides access to the .NET configuration system, which includes a per-user and per-application configuration model with inheritance of configuration settings, and a transacted installer framework. Classes exist both to use the configuration framework and to extend it. Advanced Component Services The FCL provides support for building on the COM+ services such as distributed transactions, JIT activation, object pooling, queuing, and events. The FCL also includes types that provide access to reliable, asynchronous, one-way messaging via an existing Message Queue infrastructure (MSMQ). The FCL also includes classes that provide access to existing directory services (Active Directory). Diagnostics and Debugging The FCL includes classes that provide debug tracing with multilistener support; access to the event log; access to process, thread, and stack frame information; and the ability to create and consume performance counters. Interoperating with Unmanaged Code The .NET runtime supports bidirectional interop with unmanaged code via COM, COM+, and native Win32 API calls. The FCL provides a set of classes and attributes that support this, including precise control of managed-object lifetime and the option of creating user-defined custom marshalers to handle specific interop situations. Compiler and Tool Support In the .NET runtime, components are distinguished from classes by the presence of additional metadata and other apparatus that facilitate the use of component forms packages such as Windows Forms and Web Forms. The FCL provides classes and attributes that support both the creation of components and the creation of tools that consume components. These classes also include the ability to generate and compile C#, JScript, and VB.NET source code. Runtime Facilities The FCL provides classes that can control runtime behavior. The canonical examples are the classes that control the garbage collector and those that provide strong and weak reference support. Native OS Facilities The FCL provides support for controlling existing NT services and creating new ones. It also provides access to certain native Win32 facilities such as the Windows registry and the Windows Management Instrumentation (WMI). Undocumented Types The assemblies that make up the .NET Framework also export many types and namespaces that are not documented. These types and namespaces generally represent either implementation details that are subject to change, vestigial code from earlier betas, or tool-specific code that happens to be managed and is therefore subject to examination via reflection. Regardless of the reason, one cannot count on undocumented types, nor expect any support from Microsoft. |
||||||||||||||||||||||
|
home | About me | Twins | India | Technical ref | Dot Net | Cartoon | Wife | Photo Gallery | Links | STD Codes | Contact me |
||||||||||||||||||||||