Creating a new project (File->New->Project), calling the application
ConsoleApplication2 and using C:\Projects\2.0 as the project base folder.
Select C#->Windows->Console application as the teamplate. You should end
up with a code file called Program.cs containing this piece of code
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
}
}
}
Add the following two lines making Program.cs look like this
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.ReadKey();
}
}
}
Hit F5 to run the program and verify that you get a black window with
"Hello World" written in it, and that the window closes when you hit a
(regular) key.
If I open an explorer window and browse to
C:\Projects\2.0\ConsoleApplication2 I will find another
ConsoleApplication2 folder and two files which stores the location of
other project files etc used by Visual Studio.
Browsing to this folder I will find ConsoleApplication2.exe which is the
name of my project + .exe. This is the compiled program. You can change
the name for the output file in visual studio if you like, or just rename
the file later on. This file can be copied anywhere, sent to friends etc.
The other .exe file ConsoleApplication2.vshost.exe is a Visual Studio file
and can be ignored.
The ConsoleApplication2.pdb is a debug information file. This will give
filename information and line numbers in case of an error. For instance,
if you change Main to the code below you can try running the file from a
command prompt (or else you won't have time to see the error before the
window closes) before and after deleting the pdb file (don't worry about
deleting the file, it will be recreated next time you compile your program
in visual studio).
static void Main(string[] args)
{
throw new InvalidProgramException("Help!");
}
The result should be like this with the pdb-file present
Unhandled Exception: System.InvalidProgramException: Help!
at ConsoleApplication2.Program.Main(String[] args) in
C:\Projects\2.0\Console
Application2\ConsoleApplication2\Program.cs:line 11
Without the pdb-file
Unhandled Exception: System.InvalidProgramException: Help!
at ConsoleApplication2.Program.Main(String[] args)