C# FAQ 2.5 – How do I build a C# application using Visual Studio 2005 (“Whidbey”)?

Visual Studio 2005 (“Whidbey”) is the next edition of Visual Studio .NET. Alpha versions of it have been released at conferences and road shows around the country. The most recent release at the time of this article’s writing is the “Community Technology Preview March 2004”.

While these releases have been made available, they are not final products. Microsoft will add more enhancements and features to this product by collecting feedback from testers.

This FAQ delivers a sneak preview of the new and powerful development tool. You will build a simple application that accepts user input and prints the same on to the console. This simple application will a feel for Visual C# 2005 (“Whidbey”).

Where can I get Visual Studio 2005 (“Whidbey?”)

Microsoft has been giving out copies of this product (bits) at a number of conferences and road shows including the PDC 2003 and VSLive!. Alternatively, if you have subscribed to MSDN Universal Subscription, you can request a copy of the PDC kit from your local MSDN Customer Service center.

Building a Visual Studio 2005 Application

First, you have to launch Visual Studio 2005 (“Whidbey”) (Start | All Programs | Microsoft Visual Studio Whidbey | Microsoft Visual Studio codename Whidbey).

You will be presented with a startup page. Select New Project from the File menu and choose Console Application from the Templates section. Be sure to select Visual C# from the Project Types area (See Figure 2.5.1)

Figure 2.5.1: Visual C# Project Types

Visual Studio 2005 (“Whidbey”) will automatically create a template for a console C# application, as in Visual Studio .NET 2003.

For our sample applicationy, you should delete the three comment statements below the Main() method and enter the code given in listing 2.5.1:

Listing 2.5.1

string x;
Console.WriteLine("Enter your name"); x = Console.ReadLine(); Console.WriteLine("Hello {0}",x); Console.WriteLine("Press any key to exit"); Console.Read();

As you can see, this is a simple C# console program to prompt for a name and respond to it. The first line declares a variable named x of a data type string. The prompts is then presented asking for a name to be entered. It reads the name using the ReadLine() method and prints it on the console.

With the coding done, the next step is to compile and execute the program by pressing either the F5 key or by selecting the Start option on the Debug menu. The final output will be like as shown in Figure 2.5.2

Figure 2.5.2: Output from simple console program

If you exit the project now, the IDE will ask you whether or not to save the project. Enter a desired project name and save the project to a location. You also can choose not to save the project by selecting the Discard option. If you would like to modify the program code, select the Cancel option so that you will be returned to the code editor.

Note that the above steps might differ when Microsoft releases the beta and final versions of this product later this year.

More by Author

Must Read