BC32039: la matrice dichiarata come per la variabile di controllo del ciclo non può essere dichiarata con una dimensione iniziale

Un For Each ciclo usa una matrice come variabile di iterazione, ma inizializza tale matrice.

ID errore: BC32039

Esempio

L'esempio seguente genera l'errore bc32039:

Dim arrayList As New List(Of Integer())
For Each listElement(1) As Integer In arrayList

Next

Per correggere l'errore

Rimuovere l'inizializzazione dalla dichiarazione della variabile di iterazione, come illustrato nell'esempio seguente:

Dim arrayList As New List(Of Integer())
For Each listElement() As Integer In arrayList

Next

oppure è possibile usare l'inferenza del tipo:

Dim arrayList As New List(Of Integer())
For Each listElement In arrayList

Next

Vedere anche