Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio .NET
Reference
Visual C# Language
C# Compiler Options
 /checked (Check Integer Arithmetic)
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
Visual C# Language Concepts
/checked (Check Integer Arithmetic)
/checked[+ | -]

Remarks

The /checked option specifies whether an integer arithmetic statement that is not in the scope of the checked or unchecked keywords and that results in a value outside the range of the data type shall cause a run-time exception.

An integer arithmetic statement that is in the scope of the checked or unchecked keywords is not subject to the effect of the /checked option.

If an integer arithmetic statement that is not in the scope of the checked or unchecked keywords results in a value outside the range of the data type, and /checked+ (/checked) is used in the compilation, then that statement will cause an exception at run time. If /checked- is used in the compilation, then that statement will not cause an exception at run time.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C# Project Properties.
  2. Click the Configuration Properties folder.
  3. Click the Build property page.
  4. Modify the Check for Arithmetic Overflow/Underflow property.

To set this compiler option programmatically

See CheckForOverflowUnderflow Property.

Example

Compile t2.cs and specify that an integer arithmetic statement that is not in the scope of the checked or unchecked keywords and results in a value outside the range of the data type will cause an exception at run time.

csc t2.cs /checked

See Also

C# Compiler Options

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker