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

  • Not all enterprise applications are created equal. Sophisticated applications need developer support but other more basic apps do not. With the right tools, everyone is a potential app developer with ideas and a perspective to share. Trends such as low-code development and model driven development are fundamentally changing how and who creates applications. Is your organization ready? Read this report and learn: The seven personas of enterprise app delivery How application ownership is spreading to the …

  • The explosion in mobile devices and applications has generated a great deal of interest in APIs. Today's businesses are under increased pressure to make it easy to build apps, supply tools to help developers work more quickly, and deploy operational analytics so they can track users, developers, application performance, and more. Apigee Edge provides comprehensive API delivery tools and both operational and business-level analytics in an integrated platform. It is available as on-premise software or through …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds