Variable kann nicht mit dem Nicht-Arraytyp <elementname> initialisiert werden

Eine Variable, die als Array deklariert ist, muss mit einem Arraywert initialisiert werden.

' Not valid.  
' The following line causes this error when executed with Option Strict off.  
' Dim arrayVar1() = 10  

Fehler-ID: BC36536

So beheben Sie diesen Fehler

  • Initialisieren Sie die Arrayvariable mit einem Arraywert:

    ' With Option Strict off.  
    Dim arrayVar2() = {1, 2, 3}  
    ' With Option Strict on.  
    Dim arrayVar3() As Integer = {1, 2, 3}