In this blog I will tell you that how to create dll in c# by
using notepad and visual studio command prompt. Here I will provide you a sample
algorithm which is helpful for you while creating dll in c#.
Create a class for which you want to create a
dll. Like following example will be demonstrate a sample class.
is a program which give you a demonstration that how to
a dll in c# using notepad and visual studio command prompt.
using System; //A basic namespace which is required for c#
public class Employee
is sample dll created by notepad and c# compiler.");
Save this class in a file by using valid
filename. I had save this file by using Employee.cs for this demonstration.
Now compile this file by using following syntax.
csc /target:library Employee.cs
This will create a dll for
Employee class. Here target:library will denotes that a dll should be created after compilation.
Now create another file in which create a
TestEmployee named class which used this dll. Following example will
demonstrate use of this class.
is a sample program which will execute
public class TestEmployee
static void Main()
of Employee.dll begins....");
emp=new Employee(); //Create an object
of Employee class.
emp.disp(); //Call disp() method of
of Employee.dll ends....");
Save this file by using TestEmployee.cs .
Compile this file by using following syntax.
csc /reference:Employee.dll TestEmployee.cs
Here reference word tells that Employee.dll
is added in program before compiling.
Now execute program by writing TextEmployee.exe
and see the output.