Click here to Skip to main content
15,886,693 members
Articles / General Programming / String
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
2.60/5 (5 votes)
20 Oct 2010CPOL 47.2K   3   6
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRidiculous explanation of a simple problem. :laugh: My vote... Pin
Jecka23-Nov-10 22:03
Jecka23-Nov-10 22:03 
GeneralReason for my vote of 1 Your dimensions are completely inacc... Pin
MarqW19-Nov-10 4:10
MarqW19-Nov-10 4:10 
GeneralReason for my vote of 5 :) Pin
Sherylee8-Nov-10 22:46
Sherylee8-Nov-10 22:46 
GeneralReason for my vote of 1 I agree, it is quite basic thing. Pin
Prerak Patel24-Oct-10 18:14
professionalPrerak Patel24-Oct-10 18:14 
GeneralThanx Pin
Mohunnud Basic Uglu21-Oct-10 1:00
Mohunnud Basic Uglu21-Oct-10 1:00 
GeneralReason for my vote of 1 It could be unknown to only person w... Pin
Hiren solanki21-Oct-10 0:27
Hiren solanki21-Oct-10 0:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.