Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The compiler does not infer the data type of static local variables. In the following example, with Option Strict set to Off, the type of m will be Object, regardless of whether Option Infer is set to On or Off. Local type inference does not apply.
Sub Main()
Static m = 10
End Sub
By default, this message is a warning. For information about how to hide warnings or how to treat warnings as errors, see Configuring Warnings in Visual Basic.
Error ID: BC42111
To address this warning
Specify the data type for static local variables.
For example, if you want m in the previous example to be of type Integer, specify the type in the declaration.
Sub Main() Static m As Integer = 10 End Sub
See Also
Tasks
How to: Lengthen a Variable's Lifetime