Open In App

How to Install a C# Class Library in Visual Studio?

Last Updated : 09 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A C# library project is a separate project used to hold utility classes. So this might be the class that handles our database or might handle some communications with the network. In our case, we are going to create a math library that is a stand-in for some of those other cases. It is a single source of code if we have a shared library among several projects. It is also a separation of concerns so that we do not have all our code in one class in our project. We separate it according to the layers in our project so that it could separate according to the user interface layer, business logic, or maybe data repository.

Steps To Create A C# Class Library In Visual Studio

Step 1: Open Visual Studio. The below tab will appear. Select Create a new project from the right-hand side. 

Select Create a new project

 

Step 2: The Create a new project tab page will appear from here go to the search button and search for “blank solution”. On appearing, select a blank solution. 

go to the search button and search for "blank solution"

 

Step 3: Upon selecting a blank solution, the below screen is going to appear. Select the Blank Solution option on which the mouse has been pointed and where it is written Create an empty solution containing no projects.

Select the Blank Solution option

 

Step 4: After selecting Blank Solution it will ask us to give a Solution name. Enter a solution name and click “Create”.

Enter a solution name and click "Create"

 

Step 5: After selecting create the below page will appear.

create the page

 

Step 6: Point the mouse as below on the “Solution’ MyClassSolution’ which has 0 projects at the moment. We will create a new project. So right-click over it.

Point the mouse on the "Solution' MyClassSolution'

 

Step 7: On right-clicking, the below options will appear.

 the options will appear.

 

Step 8: Point the cursor on “Add” then select “New Project”.

select "New Project"

 

Step 9: The following “Add a new project” page will be displayed.

Add a new project" page will be displayed

 

Step 10: From the search bar, search for “Class Library”. On appearing, select Class Library.

From the search bar, search for "Class Library".

 

Step 11: It will display the “Configure your new project” tab where we have to enter the Project name. The location we are keeping it as default.

display the "Configure your new project" tab

 

Step 12: We name the project “MyTriangleProj” and select “Next”.

name the project "MyTriangleProj" and select "Next".

 

Step 13: We will find the Framework displaying “NET6.0(Long term support)”. We do not need to change here anything we will keep it as it is and select create.

 find the Framework displaying "NET6.0(Long term support)"

 

Step 14: We can see below that on selecting create, the project is being created.

selecting create, the project is being created.

 

Step 15: Upon creating the project with the required library, the following class page will be displayed with the following code in it.

 creating the project with the required library, the following class page will be displayed

 

The above steps are a procedure for creating a C# Class Library in Visual Studio.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads