The .NET Base Class Library

  • The .NET Framework base class library contains the base classes that provide many of the services and objects you need when writing your applications
  • The class library is organized into namespaces
  • A namespace is logical grouping of types that perform related functions. For example, the System.Windows.Forms namespace contains all the types that make up Windows forms and the controls used in the forms
  • Namespaces are logical groupings of related classes
  • The namespaces are in the .NET base class library are organized hierarchically.
  • The root of the .NET Framework is the System namespace
  • Other namespaces can be accessed with the period operator
  • A typical namespace construction is given below
  •       System
          System.Data
          System.Data.SQLClient
         The first refers to the System Namespace
         The second refers to the System.Data
         The third refers to the System.Data.SQLClient

.NET Framework Class Library
Imports Statements
  • If you wanted to access a type in the .NET Framework base class library, you had to use the full name of the type, including every namespace to which it belonged
  • i.e. System.Windows.Forms.Form
  • This is called the fully-qualified name, meaning it refers both to the class and to the namespace in which it can be found. You can make your development environment aware of various namespaces by using the Imports statement.
  • This technique allows you to refer to a type using only its generic name and to omit the qualifying namespaces. Thus you could refer to System.Windows.Forms.Form as simply Form. This Imports statement must be placed at the top of the code window, preceding any other statement
  • Example: Imports System.Windows.Forms
Referencing External Libraries
  • You might want to use class libraries not contained by the .NET Framework, such as libraries developed by third party vendors or libraries developed by you. To access these external libraries, you must create reference
  • Follow the steps given below to create a reference to an external library:
    1. In the Solution Explorer, right click the Reference node of your project
    2. From the pop-up menu, choose Add Reference. The Add Reference dialog box appears
    3. Choose the appropriate tab for the library you want to reference. .NET libraries are available on the .NET tab. Legacy COM libraries appear on the COM tab, and local Visual Studio projects appear on the Projects tab
    4. Locate the library you want to reference, and double click OK to confirm the choice of that reference
  • A class library as shown below is created and that class library is converted into dll and used with windows application:
Public Class Class1
Public Sub display(ByVal Message As String)
MsgBox(Message)
End Sub
End Class
Public Class class2
Public Sub display(ByVal Message As String)
MsgBox(Message,MsgBoxStyle.Exclamation)
End Sub
End Class
  • Following is the Windows application using which you are going to use the class library created by you.
Public Class Form1
Dim obj1 As New ClassLibrary1.Class1
Dim obj2 As New ClassLibrary1.class2
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
obj1.display("Hello")
obj2.display("Hai I am fine")
End Sub
End Class


The .Net Framework and the Common Language Runtime << Previous

Next >> Reference Types and Value Types

Our aim is to provide information to the knowledge


comments powered by Disqus








Footer1