This website may use cookies. More info. That's Fine x
Welcome Login

Visual studio: Creating a class library project


Visual Studio 2010

Steps:

1. Start a new project, choose class library.

vs-addemptyproject2

 

vs-classlibrary1

 

2. The class libary project name is used for the namespace name.

3. Add class: Right click on class library project > Add > New Item... > Visual C# Items > Code > Class

vs-addemptyproject5

 

4. Note: if you add a class in a folder, Namespace will be [Namespace].[folder].  Just delete the folder name in the namespace if you want to simplify class library namespace name.

5. To use a class library within a project, add the class libary reference to the project.

vs-addemptyproject4

 

6. To access properties/methods of a class library, make sure the access modifier is 'public' for the class

vs-addemptyproject6

 

 

Note: You can check that your project is a class library in properties:

vs-addemptyproject3

 

 

 

Class Library project templates:

In latest versions of visual studio, you can select whether to use an empty class library or one with an asp.net framework:

Eg:

vs-classlibrary2


Created on: Tuesday, September 6, 2011 by Andrew Sin