![]()
|
Advice for using the Microsoft Visual StudioThe Microsoft Visual Studio is an integrated program development environment that can be used to write, compile, and execute C# programs. The Visual Studio is thus an alternative to the free programming tools that are explained in the book.The Visual Studio may be a somewhat confusing tool for a beginner in the field of computer programming because you can develop many kinds of computer applications with it, and it supports the Visual Basic and C++ programming languages in addition to the C# programming language. On the other hand, the Visual Studio is a very powerful tool if you learn to use it. There exist many versions of the Visual Studio, and some of the versions can be downloaded and used freely. To get a free version of the Visual Studio, you should go to this address and follow the given instructions. Please, make sure that you select the C# version of the Visual Studio. The free versions of the Visual Studio are called Express Editions. All C# versions of the Visual Studio should be able to compile and run the programs that are presented in A Natural Introduction to Computer Programming with C#. Generally, you need to set up a project in the Visual Studio before you can start working with a program. How a project is exactly set up depends on the version of the used Visual Studio. The following paragraphs explain how a simple C# program is compiled and executed with the 2003 version of the non-free Visual Studio. Let's suppose that you want to compile and execute the program Game.cs which is explained in Chapter 5 of the book, and stored in folder csfiles2 if you have installed the example programs as suggested in Chapter 2 in the book. Before you can compile and run a program in the Visual Studio, you must create a project to do these activities. Thus you must select File > New > Project. You might name the project Game, and it is a good idea to have a folder into which you can create your C# projects. You might name your projects folder mycsprojects. When you create the project, you must select Visual C# projects as Project Type, and use the Empty Project template. After you have created the Game project, you must add the Game.cs file to the project. This can be done by first right-clicking the project's name Game in the Solutions Explorer subwindow, then selecting Add ... > Add Existing Item, then selecting folder csfiles2, and finally selecting Game.cs. After these selections, the the Game.cs file will be copied from the csfiles2 folder to the Game project folder. (An alternative way to add a file to a project is to use the Project menu.) When Game.cs is in the project folder, you can compile the program. To compile a program in the Visual Studio world, you must build the project into which the program belongs to. Thus to compile, select Build > Build Game. After the Game project has been built successfully, you can run the program by selecting Debug > Start Without Debugging. When you write your own C# programs with the Visual Studio,
you should select the Console Application template when you create the
project for your programs. The Visual Studio automatically creates a template
for your program.
© Kari Laitinen
Last modification of this page: January 15, 2009
|