2. Installing Visual C# 2008
At the end of January 2008, Express versions of Visual Studio 2008 were available for download [2] at the following address [1]: [http://msdn2.microsoft.com/en-fr/express/future/default(en-us).aspx] :
![]() |
- [1]: download address
- [2]: Downloads tab
- [3]: download C# 2008
When you install C# 2008, you'll also be installing :
- the .NET 3.5 framework
- the SGBD SQL Server Compact 3.5
- documentation MSDN
To create your first program with C# 2008, proceed as follows after launching C# :
![]() |
- [1]: take option File / New Project
- [2]: choose a Console application
- [3]: give the project a name - it will be changed below
- [4b]: the project created
- [4c] : Program.cs is the C# program generated by default in the project.
![]() |
- step 1 didn't ask where to save the project. If we do nothing, it will be saved in a default location that will probably not suit us. The option [5] is used to save the project in a specific folder.
- you can give the project a new name in [6] and specify its folder in [7]. To do this, you can use [8]. if you choose Ici, the project will end up in the folder [C:\temp\08-01-31MyApplication1].
- by checking [9], you can create a folder for the solution named in [10]. If Solution1 is the name of the solution:
- a folder [C:\temp\08-01-31\Solution1] will be created for the solution Solution1
- a folder [C:\temp\08-01-31\Solution1\MyApplication1] will be created for the project MyApplication1. This solution is well suited to solutions made up of several projects. Each project will have a subfolder in the solution folder.
![]() |
- in [1]: the file windows the project MyApplication1
- in [2]: its contents
- in [3]: the project in Visual Studio's Project Explorer
Let's modify the code of file [Program.cs] [3] as follows:
using System;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.WriteLine("1er essai avec C# 2008");
}
}
}
- line 3: the namespace of the class defined on line 4. The full name of the class defined on line 4 is ici ConsoleApplication1.Program.
- lines 5-7: the static method Main which is executed when the execution of a
- line 6: a screen display
The program can be run as follows:
![]() |
- [Ctrl-F5] to run the project, in [1]
- in [2], the console display is obtained.
Execution has added files to the :
![]() |
- in [1], display all project files
- in [2]: the [Release] folder contains the project executable [MyApplication1.exe].
- in [3]: the [Debug] folder, which would also contain an executable [MyApplication1.exe] of the project had it been run in [Debug] mode (F5 key instead of Ctrl-F5). This is not the same executable as the one obtained in [Release] mode. It contains additional information enabling the debugging process to take place.
A new project can be added to the current solution:
![]() |
- [1]: right-click on the solution (not the project) / Add / New Project
- [2]: select an application type
- [3]: the default folder is the one containing the existing project folder [MyApplication1]
- 4: name the new project
The solution then has two projects:
![]() |
- [1]: the new project
- [2]: when the solution is executed using (F5 or Ctrl-F5), one of the projects is executed. This is called [2].
A project can have several executable classes (containing a Main method). In this case, the class to be executed when the project is run must be specified:
![]() |
- [1, 2]: copy/paste file [Program.cs]
- [3]: copy/paste result
- [4,5]: rename the two files
![]() |
Class P1 (line 4):
using System;
namespace MyApplication2 {
class P1 {
static void Main(string[] args) {
}
}
}
P2 class (line 4):
using System;
namespace MyApplication2 {
class P2 {
static void Main(string[] args) {
}
}
}
The [MyApplication2] project now has two classes with a static method Main. The project must be told which :
![]() |
- in [1]: project properties [MyApplication2]
- in [2]: select the class to be executed when the project is run (F5 or Ctrl-F5)
- in [3]: type of executable produced - ici a Console application will produce an .exe file.
- in 4: the name of the executable produced (without the .exe)
- en [5]: the default namespace. This is the one that will be generated in the code of each new class added to the project. It can then be changed directly in the code, if required.










