| title | -optionstrict | |||
|---|---|---|---|---|
| ms.date | 07/20/2015 | |||
| ms.prod | .net | |||
| ms.reviewer | ||||
| ms.suite | ||||
| ms.technology |
|
|||
| ms.topic | article | |||
| f1_keywords |
|
|||
| helpviewer_keywords |
|
|||
| ms.assetid | c7b10086-0fa4-49db-b3c8-4ae0db5957da | |||
| caps.latest.revision | 17 | |||
| author | dotnet-bot | |||
| ms.author | dotnetcontent |
Enforces strict type semantics to restrict implicit type conversions.
-optionstrict[+ | -]
-optionstrict[:custom]
+ | -
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.
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.
-
Have a project selected in Solution Explorer. On the Project menu, click Properties.
-
Click the Compile tab.
-
Modify the value in the Option Strict box.
The following code compiles Test.vb using strict type semantics.
vbc -optionstrict+ test.vb 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