Cannot infer a data type for '<variablename>' because the array dimensions do not match

If the dimensions used to initialize an array do not match the dimensions in the declaration, the compiler cannot infer a data type for the array. For example, the following code causes this error.

' Valid. exampleArray1 is a one-dimensional array of integers.
Dim exampleArray1() = New Integer() {1, 2, 3}
' Not valid.
'Dim exampleArray2(,) = New Integer() {1, 2, 3}
'Dim exampleArray3(,) = New Integer() {}

Error ID: BC36909

See Also

Tasks

How to: Initialize a Multidimensional Array

Concepts

Local Type Inference