which will restrict the implicit type casting (defalut is off in vb.net)
kumaraswamy
Oct 18th, 2005
Option Strict
Visual Basic language in general does not require explicit syntax to be used when performing operations that might not be optimally efficient (e.g. late binding) or that might fail at run time (e.g. narrowing conversions). This permissive semantics often prevents detection of coding errors and also affects the performance of the application.
VB.NET enables a programmer to enforce strict semantics by setting this option to "On". When used, this option should appear before any other code. This option can be set to "On" or "Off". If this statement is not specified, by default, it is set to "Off".
Syntax:Option Strict [On / Off]
When it is set to "On", it disallows any narrowing conversions to occur without an explicit cast operator, late binding and does not let the programmer omit "As" clause in the declaration statement. Since setting it to "On" requires explicit conversion, it also requires that the compiler be able to determine the type of each variable. Thus it is implied that Option Strict also means Option Explicit.
Visual Basic .NET allows implicit conversions of any data type to any other data type. However, data loss can occur if the value of one data type is converted to a data type with less precision or a smaller capacity. Setting this option to "On" ensures compile-time notification of these types of conversions so they may be avoided.
Henry
Jan 5th, 2006
It is a keyword used to restrict implicit type casting if its set to on because Visual basic provides implicit type conversion between any data types whereas In C#.net is strong type safe language
sabir
Jan 13th, 2006
this is the concept in vb where in vb we are option strict is indiacted that the when ever we use the verible that it has to be declared else it will thuorgh error but in vb by defalut the option strict =off but in case if net option strict will be on
Anuj
Nov 14th, 2007
When we want that type conversion of data types must done explicitly then we enable the 'Option Strict'.
Neelam
Nov 16th, 2007
IfOff- Implicit conversion is allowed
If On – Implicit conversion is not allowed. U need to use system.convert
e.g of Implicit conversion and Explicit conversion
What do you mean by 'Option Strict On' ?