ArrayList/String Array question

Results 1 to 2 of 2

Thread: ArrayList/String Array question

  1. #1
    Join Date
    Dec 1969

    Default ArrayList/String Array question

    This should be an easy one. I need to get the contents of an ArrayList to a string array so that I can combine them all in one string:<BR><BR>Dim StringArray() = arrArtists.ToArray()<BR>Dim strArtists<BR>strArtists.Join("&#124", StringArray)<BR><BR>This is invalid. What do I need to do differently? Thanks in advance for any help.

  2. #2
    Join Date
    Dec 1969

    Default Read the docs... asp<BR><BR> asp<BR><BR>Your code is creating an array of Object, not an array of String.<BR><BR>By the way, if you haven&#039;t learned to put <BR> Option Strict On<BR>at the top of *EVERY* page of VB.NET code you write, you will go around with this kind of problem from now to doomsday. Trust me, the minor pain that causes when you are writing code is WAY MORE than made up for by the improvement in your overall success rate.<BR><BR>And your JOIN is backwards and missing an equals sign.<BR><BR>So the right answer, by the way, (and assuming you have found the light and added Option Strict On) is:<BR><BR>Dim StringArray As String() = CType( arrArtists.ToArray(GetType(String())), String() )<BR>Dim strArtists As String<BR>strArtists = Join( StringArray, "&#124" )<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts