Introduction

This article explains how to create a Class Library and how to use a Class Library (Calculator.dll) in a Console Application.

Procedure to Create a Class Library

Sample Usage of Calculator.dll in a Console Application

Use the following procedure to create a sample use of the preceding class library (Calculator.dll) in a Console Application.

  1. Create a new Console Application in Visual Studio.
  2. Add a reference to the calculator.dll as follows to access the classes and methods of the DLL in the application as follows.
  3. Go to Solution Explorer.
  4. Right-click on the References Node.
  5. Select the Option Add Reference.
  6. It will display a dialog box with a few tabs on it. Click the Browse tab. Browse to where you saved your Class Library. Then locate the Bin > Debug folder from above. Your DLL will be in there.

    DLL
    Click OK to add the reference to your DLL. To call the methods from the preceding Library, include the namespace, calculator.
    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Text;  
    using Calculator;  
    Create the object of the class Class1 that contains the methods and call them as follows.
    Object of the class

Run your programme. This is an easy way to create your own class libraries and reuse it in any .Net application and in any .Net Language.