Value of type ‘List(Of String); cannot be converted to ‘String()’

I saw these 2 string examples on this link.

https://www.dotnetperls.com/convert-list-string-vbnet

I doing the first one using String.Join

I created a new page called Default.aspx and put a label called Label1 on the page

Then on this page Default.aspx.vb in the page load event I put this code.
Then when I run the page it works fine and the string is displayed on my label.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        ' Create list of three strings.
        Dim vals As List(Of String) = New List(Of String)
        vals.Add("dot")
        vals.Add("net")
        vals.Add("perls")

        ' Use string join function that receives IEnumerable.
        Dim value As String = String.Join(",", vals)

        'Show String On Label
        Label1.Text = value

    End Sub

Open in new window




I have a .net 3.5 ASP.NET Web Forms application using VB.

In the page load event of my page I put the same code.

But I get this error message:

error
Any idea of why I'm getting this error message saying Listing(Of String) cannot be converted to String?
LVL 1
maqskywalkerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul JacksonSoftware EngineerCommented:
The code you are using is .Net 4.0, in .Net 3.5 you need to use vals.ToArray() as the second argument to the Join :
Dim value As String = String.Join(",", vals.ToArray())

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maqskywalkerAuthor Commented:
Thanks. Good info!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.