Permalink
Fetching contributors…
Cannot retrieve contributors at this time
91 lines (72 sloc) 3.24 KB
title ms.date ms.prod ms.reviewer ms.suite ms.technology ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author translation.priority.ht
/optionstrict
2015-07-20
.net
devlang-visual-basic
article
/optionstrict
VB
-optionstrict compiler option [Visual Basic]
optionstrict compiler option [Visual Basic]
/optionstrict compiler option [Visual Basic]
c7b10086-0fa4-49db-b3c8-4ae0db5957da
17
dotnet-bot
dotnetcontent
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

/optionstrict

Enforces strict type semantics to restrict implicit type conversions.

Syntax

/optionstrict[+ | -]  
/optionstrict[:custom]  

Arguments

+ | -
Optional. The /optionstrict+ option restricts implicit type conversion. The default for this option is /optionstrict-. The /optionstrict+ option is the same as /optionstrict. You can use both for permissive type semantics.

custom
Required. Warn when strict language semantics are not respected.

Remarks

When /optionstrict+ is in effect, only widening type conversions can be made implicitly. Implicit narrowing type conversions, such as assigning a Decimal type object to an integer type object, are reported as errors.

To generate warnings for implicit narrowing type conversions, use /optionstrict:custom. Use /nowarn:numberlist to ignore particular warnings and /warnaserror:numberlist to treat particular warnings as errors.

To set /optionstrict in the Visual Studio IDE

  1. Have a project selected in Solution Explorer. On the Project menu, click Properties. For more information, see Introduction to the Project Designer.

  2. Click the Compile tab.

  3. Modify the value in the Option Strict box.

To set /optionstrict programmatically

Example

The following code compiles Test.vb using strict type semantics.

vbc /optionstrict+ test.vb  

See Also

Visual Basic Command-Line Compiler
/optioncompare
/optionexplicit
/optioninfer
/nowarn
/warnaserror (Visual Basic)
Sample Compilation Command Lines
Option Strict Statement
Visual Basic Defaults, Projects, Options Dialog Box