Convert a Console App to Class Library

The big difference, you can run a console app but you can’t run a class library. Usually, Console App has Program.cs file and will compile to .exe file, a class library by default is not executable and will compile to a .dll. In .NET Core console app can also compile to DLL.

A Console App has a flow and can be executed. A Class Library is just a collection of functions that you call from another source. Class libraries by themselves are pretty useless without something to call the functions inside them.

Console App has a static MAIN method that’s an entry point. When deciding to make a method or Static class, I always keep this in mind.

A static class can be used as a convenient container for sets of methods that just operate on input parameters and do not have to get or set any internal instance fields.

Create console app. Add a greeting method. Run the app. Switch the output type to Class Libarary. Right-Click on Project -> Properties;

Before;

After;

You have best of the both worlds.

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect