| The example shown below does not have Main entry point, because I am going to use it as a dll in many other examples. The take home message of this example is to introduce the concept of "constructor and destructor". A constructor or destructor will have the same name of the class, and compiler will know for sure that a class of "xyz" exists. |
///contructor_dll.cs
//------this one will not complie------ //Compilation is done using "csc /target:library contructor_dll.cs " using System; //UseName.cs is the file which uses this dll. namespace DllCon { public class add_different { // this one will not compile public add() { Console.WriteLine("Constructor evoked"); } ~add() { Console.WriteLine("Destructor evoked"); } public int bonus(int b, int a) { int n = a + b ; Console.WriteLine("Hi,Your Total Sal is" + n + " this returns through dll"); return n; } } } |
![]() ![]() ![]() |
| For a compiled version please review these examples. 1, 2 |