03.01.2015 Views

C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Preprocessor Directives ❘ 31<br />

The second tab opens Team Explorer, a tool that helps you manage<br />

your work in a team environment. For more information, see<br />

msdn.microsoft.com/library/hh500420.aspx.<br />

The third tab opens the Class View. This tool enables you to view<br />

the classes defined by your projects. You can expand the classes to<br />

learn about their inheritance hierarchies. If you click a class, the bottom<br />

of the window shows you the class’s properties, methods, and<br />

events. If you double-click one of these items, Visual Studio opens<br />

the code that defines it in the Code Editor.<br />

Figure 3-4 shows the Class View displaying information about the<br />

Turtle class defined in the TurtleLib project.<br />

Some projects may have other hidden files. For example, when you<br />

add controls to a form, the designer adds a resource file to the form<br />

to hold any resources needed by the controls.<br />

Normally, you do not need to work directly with the hidden files,<br />

and doing so can mess up your application. At best, the changes<br />

you make will be lost. At worst, you may confuse Visual Studio, so<br />

it can no longer load your project.<br />

Instead you should use other tools to modify the hidden files<br />

indirectly. For example, the files holding resources used by a<br />

form are automatically updated when you modify the form and<br />

its controls.<br />

Figure 3-4: The Class View<br />

lets you examine the classes<br />

defined by a project.<br />

Preprocessor Directives<br />

Preprocessor directives are commands for the <strong>C#</strong> compiler. They tell the compiler such things as<br />

which pieces of code to include in compilation and how the Code Editor should group lines of code.<br />

The following sections describe the most useful <strong>C#</strong> preprocessor directives.<br />

#define and #undef<br />

The #define directive defines a preprocessor symbol that you can then use with the #if, #else,<br />

#elif, and #endif directives described next. Preprocessor symbols are either defined or not defined.<br />

They do not have values like constants inside the code do.<br />

NOTE A program can create variables and constants with the same names as<br />

defined preprocessor symbols.<br />

The #undef directive removes the definition of a defined symbol.<br />

The #define and #undef directives must come before any programming statements including using<br />

directives. They apply for the entire file that contains them.<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!