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.



About the Author

Anand Narayanaswamy

Anand Narayanaswamy (Microsoft MVP) is a freelance writer for Developer.com and Codeguru.com. He works as an independent consultant and runs NetAns Technologies (http://www.netans.com)which provides affordable web hosting services. He is the author of Community Server Quickly (http://www.packtpub.com/community-server/book). Anand also runs LearnXpress.com (http://www.learnXpress.com) and Dotnetalbum.com (http://www.dotnetalbum.com) and regularly contributes product and book reviews for various websites. He can be reached at ananddotnet@yahoo.co.in

Comments

  • How is this useful????

    Posted by keeg_hexor on 05/16/2004 08:26am

    I can't understand how this would be useful to anyone. I mean... what is this?? "...execute the program by pressing either the F5 key". "...the IDE will ask you whether or not to save the project". "also can choose not to save the project by selecting the Discard option". I understand that u have taken some time to compile this article, but people comming here definately know how to open and compile a simple project. And one more thing... how is this procedure different from the usual method? My $0.02

    • How is this useful????

      Posted by Brad Jones on 09/21/2006 04:42pm

      This FAQ article was written with the newbie in mind, not the experienced "Code Guru"

      Reply
    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds