15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

386 ❘ ChaPTer 16 visuAl studiO 2010<br />

setting the startup Project<br />

Bear in mind that if you have multiple projects in a solution, only one of<br />

them can be run at a time! When you compile the solution, all the projects<br />

in it will be compiled. However, you must specify which one you want<br />

Visual Studio to start running when you press F5 or select Start. If you<br />

have one executable <strong>and</strong> several libraries that it calls, this will clearly be<br />

the executable. In this case, where you have two independent executables<br />

in the project, you would simply need to debug each in turn.<br />

You can tell Visual Studio which project to run by right-clicking that<br />

project in the Solution Explorer window <strong>and</strong> selecting Set as Startup<br />

Project from the context menu. You can tell which one is the current<br />

startup project — it is the one that appears in bold in the Solution<br />

Explorer window (ConsoleApplication1 in Figure 16-12).<br />

Windows application Code<br />

A Windows application contains a lot more code right from the start<br />

than a console application when Visual Studio first creates it. That is<br />

because creating a window is an intrinsically more complex process.<br />

Chapter 39, “Windows Forms,” discusses the code for a Windows<br />

application in detail. For now, look at the code in the Form1 class in<br />

the WindowsApplication1 project to see for yourself how much is<br />

auto-generated.<br />

figure 16-12<br />

exploring <strong>and</strong> Coding a Project<br />

This section looks at the features that Visual Studio provides to help you add code to your project.<br />

The folding editor<br />

One really exciting feature of Visual Studio is its use of a folding editor as its default code editor.<br />

Figure 16-13 shows the code for the console application that you generated earlier. Notice those little minus<br />

signs on the left-h<strong>and</strong> side of the window. These signs mark the points where the editor assumes that a new<br />

block of code (or documentation comment) begins. You can click these icons to close up the view of the<br />

corresponding block of code just as you would close a node in a tree control (see Figure 16-14).<br />

figure 16-13<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!