该上下文中不支持可以为 null 的类型推理Nullable type inference is not supported in this context

值类型和结构可以声明为 null。Value types and structures can be declared nullable.

Dim a? As Integer  
Dim b As Integer?  

但是,不能将可为 null 的声明与类型推理结合使用。However, you cannot use the nullable declaration in combination with type inference. 下面的示例将导致此错误。The following examples cause this error.

' Not valid.  
' Dim c? = 10  
' Dim d? = a  

错误 ID: BC36629Error ID: BC36629

更正此错误To correct this error

  • 使用 As 子句将变量声明为可以为 null 的值类型。Use an As clause to declare the variable as a nullable value type.

另请参阅See also