Home Contact Us Site Map
Thursday, April 26, 2018
Article written by Samuel Mela

Visual C# Express - Projects and Solutions (2nd in a series)

When you first begin writing programs in the Visual C# Express IDE (Integrated Development Environment) you will notice that nearly every file you create must be contained in a "project" and every working program you create will consist of one or more projects contained in a "solution".

So what is so important about projects and solutions? Why do you need them? Why can't you just write programs?

This article will answer the above questions and will talk about how to use projects and solutions to write better more maintainable programs.

In the Beginning

Early programmers wrote very simple programs. Often the programs were so simple they were contained in one file. But, as computers grew in complexity and functionality, programs became so large they had to be split up into multiple files; and after a while, sets of files, were grouped together by function into reusable libraries. Simple top level programs (called application programs) were often written very quickly by incorporating libraries.

Enter Microsoft IDE: Managing the Pieces

Writing programs with with libraries and application programs is very powerful and fast, but the programmer is managing many more files and program modules. Dealing with all the files in a program as one long list can be confusing, tedious, and error prone; and that is why Microsoft created the notion of "projects" and "solutions" in the Visual C# development environment.

In general, projects are collections of code files and related management files and resources; solutions are projects grouped together to form a program.

Canned Projects

To make your life easier, Microsoft put together some "canned" projects to do specific tasks. When you first create a project the IDE offers a selection of canned projects to choose from. Three of the most important are the Windows Application project, the Console Application project, and the Class Library project. These are described in detail below:

The Windows Application Project sets up a basic windows program. In fact, after you create this project, you can immediately build and run it and it will display an empty Windows form on your screen. This project is stand alone, in the sense that you do not need to combine it with any other libraries or projects to create a working program.

The Console Application Project sets up a basic DOS Console type program. It is quite similar to the Windows Application Project, except it reads from and writes to a DOS Console. This project is also stand alone, in the sense that you do not need to combine it with any other libraries or projects to create a working program.

The Class Library Project is a completely different animal from the above two projects. You cannot create a working program directly from a Class Library Project. Instead, the library contains classes that can be used as an ingredient in a larger program.

Combining Projects into Solutions

In general, you cannot create a running program under Visual C# Express IDE without a solution; and that solution will need to contain at least one project.

As an example, I have created a program to do compound interest calculation. The program is contained in a solution called "InterestCalculatorSolution", which in turn contains the Windows Application Project called "InterestCalculator", and a Class Library Project called "FinancialLib".

You can find a copy of the Interest Calculator Code can be on my Article Support Page.

Create Your Own Solution

After looking at my example, you will probably want to create your own. It could not be simpler.

1. Start the C# Express application.
2. Click on the "File" menu item.
3. Click on "New Project", and select one of the new project icons when the "New Project" dialog box pops up. I suggest a "Windows Application".
4. Give the project a name (text box at the bottom of the dialog window), click "Ok", and C# Express will create a new solution and a new project with the same name.

You can see icons for both the the solution and the project in the "Solution Explorer" on the right side of the application window.

Now you need to add some features to your project, but that will be the subject of future articles.


Projects and Solutions are a modern visually oriented way to organize code applications and libraries which help you to create well organized software from reusable pieces. Fire up your IDE and give them a try.
Related Searches

application project, project solution, application window, class library