create_dll_1.htm | |
///use_dll.cs //------------ //Compilation is done using "csc /target:library use_dll.cs " using System; //UseName.cs is the file which uses this dll. namespace DllHello { public class Hello { public Hello() { Console.WriteLine("Constructor evoked"); } ~Hello() { Console.WriteLine("Destructor evoked"); } public string Msg(string str) { return ("Hi," + str + " this returns through dll"); } } } |
//test_dll.cs // compile "csc /reference:use_dll.dll test_dll.cs" using DllHello; using System; public class test { public static void Main() { Hello hello = new Hello(); Console.WriteLine("Enter Your Name: "); string str = Console.ReadLine(); System.Console.WriteLine(hello.Msg(str)); } } |
create a library with "csc /target:library use_dll.cs"
|
|
The library successfully created
|
|
create executable
|
|
executable created
|
|
run executables and then enter some word
|
|
You get get the out-put as shown below
|
|
Now dll can be created and placed within the similar directory structures and use it as you wish. Check the second example | |