如何String.Join一个字符串()

时间:2018-05-16 14:37:19

标签: vb.net razor visual-studio-2015 .net-4.7

我做错了,因为当我尝试String.Join以下时,我得到一个结果字符串“System.String []”:

Dim MyList As String()

' DB select here returns a comma delimited column value
' using dr As DataRow

MyList = dr("someColumnn").trim.trim(",").split(",") 
' Debug watch on MyList at this point shows:
'   Name: MyLIst, Value: {Length=1}, Type: Object {String()}
' And when I expand that entry I see:
'   Name: (0), Value: "Item1", Type: String

' Then in the Razor page:
List: @String.Join(" | ", MyList)
' Displays: 
'   List: System.String[]

' EDIT: This is the workaround I am doing for now:
Dim L As New List(Of String)
For Each Item As String In MyLIst
    L.Add(Item)
Next

' In the razor page:
@String.Join(", ", L) 

我做错了什么?

0 个答案:

没有答案