Solving "Value of type 'String' cannot be converted to '1-dimensional array of String'."






2.60/5 (5 votes)
While working with String Arrays, the most common error we come across will be :
"Value of type 'String' cannot be converted to '1-dimensional array of String'."
As in a hurry we forget that we are dealing with arrays.
Usually we do declare an array as
Dim arr as String[]
or Dim arr[] as String
But in a hurry, during initialization we try
arr = "6"
or
arr = {"6"}
or
arr = New String("6")
But still we get the same error.
Initialize the array as below :
arr = New String() {"6"}
and it will solve our problem.