---
title: "Creating dll in c#."  
description: "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 algorit"  
author: "Anonymous User"  
published: 2011-06-13  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/189/creating-dll-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Creating dll in c#.

In this blog, I will tell you that how to create [dll in c#](https://www.mindstick.com/forum/271/how-can-we-create-dll-in-c-sharp) by using notepad and [visual studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) [command prompt](https://answers.mindstick.com/qa/51716/how-to-make-bootable-pendrive-using-cmd-windows-command-prompt). Here I will provide you a sample [algorithm](https://www.mindstick.com/blog/119/implementing-cryptography-in-c-sharp-dot-net-by-using-sha1-algorithm) which is helpful for you [while creating](https://www.mindstick.com/forum/105382/which-constraints-we-can-use-while-creating-a-database-in-sql) dll in c#.\

1) Create a class for which you want to create a dll. Like following example will be demonstrate a sample class.

\

```
/*     This is a program which give you a demonstration that how to   make a dll in c# using notepad and visual studio command prompt.*/using System;   //A basic namespace which is required for c# program.public class Employee{     public void disp()     {    Console.WriteLine("This is sample dll created by notepad and c# compiler.");       }        } 
```

2) Save this class in a file by using valid filename. I had save this file by using [Employee](https://www.mindstick.com/articles/85431/remote-employee-training-tips-tricks).cs for this demonstration.

3) Now compile this file by using following syntax.

##### csc /target:library Employee.cs

This will create a dll for Employee class. Here target:[library](https://www.mindstick.com/forum/34615/software-framework-vs-library) will denotes that a dll should be created after compilation.

4) Now create another file in which create a TestEmployee named class which used this dll. Following example will demonstrate use of this class.

```
/*                This is a sample program which will execute                Employee.dll*/using System;public class TestEmployee{                public static void Main()                {                                Console.WriteLine("Testing of Employee.dll begins....");                                Employee emp=new Employee();   //Create an object of Employee class.                                emp.disp();                    //Call disp() method of Employee class.                                Console.WriteLine("Testing of Employee.dll ends....");                }} 
```

5) Save this file by using TestEmployee.cs .

6) Compile this file by using following syntax.

csc /[reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php):Employee.dll TestEmployee.cs

Here reference word tells that Employee.dll is added in program before compiling.

7) Now [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) program by [writing](https://www.mindstick.com/articles/12997/5-essential-tips-on-resume-writing-for-business-analysts) TextEmployee.exe and see the output.

---

Original Source: https://www.mindstick.com/blog/189/creating-dll-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
