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.

Code File Structure ❘ 37<br />

{<br />

...<br />

}<br />

#pragma warning restore 1591<br />

}<br />

...<br />

The class begins with an XML comment, so it doesn’t cause a warning. The PrintTimesheet<br />

method does not have an XML comment, so it would cause a warning if the #pragma warning<br />

disable directive didn’t disable the error.<br />

After the PrintTimesheet method ends, the code restores the warning, so the compiler can report it<br />

for the class’s later public members.<br />

The #pragma checksum directive has the following format.<br />

#pragma checksum "file" "{guid}" "bytes"<br />

This directive is useful for debugging ASP.NET applications. It’s outside the scope of this book, so<br />

it isn’t described here. For more information, see msdn.microsoft.com/library/ms173226.aspx.<br />

Finding Warning Numbers<br />

Unfortunately, the Error List doesn’t display the warning numbers you need to<br />

use with the #pragma warning directive. One way to find a warning number is to<br />

right-click the warning in the Error List and select Show Error Help. That opens a<br />

web page that describes the warning and gives the warning number.<br />

You can find a summary of compiler errors and warnings at msdn.microsoft<br />

.com/library/vstudio/ms228296.aspx, although the warnings are listed by<br />

number and not name, so that won’t help you find the number you want.<br />

Code File Structure<br />

The following code shows the file Form1.cs from a newly created program named<br />

WindowsFormsApplication1. This is a Windows Forms program created in Visual Studio<br />

Express 2012 for Windows Desktop.<br />

using System;<br />

using System.Collections.Generic;<br />

using System.ComponentModel;<br />

using System.Data;<br />

using System.Drawing;<br />

using System.Linq;<br />

using System.Text;<br />

using System.Threading.Tasks;<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!