A guide to creating class libraries in c#: The Caesar Cipher part one

May 07 2012

A guide to creating class libraries in c#: The Caesar Cipher part one

So what are these class library things?

A class library is a way to bundle up all of the types in a project into a single file called a class library. The idea is that you can then give this DLL file (DLL stands for dynamic linked library) to other developers who can reference it in their own applications and make use of your types.

But what use is that?

So, suppose that I had made some kind of awesome library (such as a really bad cryptography library) and I wanted anybody who was daft enough to be able to use it, but I didn’t really want to distribute my source code and project files. Well in that case, I could just offer a download of my DLL file and other people would be able to use it!

Sounds good, tell me more

In this example I am going to show you how to build a simple class library with just one class in it, which implements the caesar cipher (More on that in part 2!)

How do I get started?

First of all, please note that I am using Microsoft Visual Studio 2010 Professional for this tutorial. I believe other IDEs will behave in a similar manner, but you may have to do a little bit of research to figure out how to start a class library project if you aren’t using MSVS 2010.
With that said, when you start a project, you will want to select the right template. It can be found under “Visual C# >> Windows” and you need to click “Class Library” and enter a name for your project (I called mine “CaesarLib” and I suggest you do the same if you are following along)

Here is a picture to help you find the correct template :

When the project loads up, you will have a single Class1.cs file in your project explorer. I deleted that file to give myself a blank slate. I will later create one source file for each type I create.

Show us some code man!

In the next part I will talk about the caesar cipher and show you how to implement it.

Leave a Reply