Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

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

0.00/5 (No votes)
20 Oct 2010 1  
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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here