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.

Working with Visual studio 2010 ❘ 387<br />

figure 16-14<br />

This means that while you are editing you can focus on just the areas of code you want to look at, <strong>and</strong> you<br />

can hide the bits of code you are not interested in working with at that moment. If you do not like the<br />

way the editor has chosen to block off your code, you can indicate your own blocks of collapsing code<br />

with the <strong>C#</strong> preprocessor directives, #region <strong>and</strong> #endregion, which were examined earlier in the<br />

book. For example, to collapse the code inside the Main() method, you would add the code shown in<br />

Figure 16-15.<br />

figure 16-15<br />

The code editor will automatically detect the #region block <strong>and</strong> place a new minus sign by the #region<br />

directive, as shown in Figure 16-15, allowing you to close the region. Enclosing this code in a region means<br />

that you can get the editor to close the block of code (see Figure 16-16), marking the area with the comment<br />

you specified in the #region directive. The compiler, however, ignores the directives <strong>and</strong> compiles the<br />

Main() method as normal.<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!