Sunday, July 22, 2018

How do you create a Class Library .NET Framework project?

When you choose C#'s Class Library (Framework) Project in Visual Studio, this is what you will be creating. The image shows the folder structure in the Solution Explorer and the .cs file created.


ClassLibFrame_0

It basically provides a template for creating a Class file, Class1.cs that uses the references appropriate for using the Framework library using Microsoft.CSharp.

You can write code appropriate to do something for this Class. 

For example, you may provide two string variables to the class to generate a concatenated string (using the + operator). The name you give to the project, is its namespace.

The following Class1.cs is what you need to concatenate two strings.


ClassLibFrame_1.png

The important step is to write the correct code that will be accepted by the build process.
When you build this project, this is what you should see:


ClassLibFrame_2.png

This class returns a value which cannot be executed directly. If you try to debug this project you will get this message.


No comments: