【发布时间】:2011-03-11 18:54:19
【问题描述】:
如何将字符串转换为数组?
值作为字符串传递:
Dim strInput as string
strInput = "Tom, John, Jason, Mike"
我的错误信息是:Value of type 'String' cannot be converted to 'System.Array'
【问题讨论】:
如何将字符串转换为数组?
值作为字符串传递:
Dim strInput as string
strInput = "Tom, John, Jason, Mike"
我的错误信息是:Value of type 'String' cannot be converted to 'System.Array'
【问题讨论】:
Dim source As String = "Tom, John, Jason, Mike"
Dim stringSeparators() As String = {","}
Dim result() As String
result = source.Split(stringSeparators, _
StringSplitOptions.RemoveEmptyEntries)
或使用Microsoft.VisualBasic.Strings.Split:
Dim source As String = "Tom, John, Jason, Mike"
Dim result() As String = Split(source, ",")
【讨论】:
你可以使用 split()。见here。
【讨论】:
strInput.Split(New String() {", "}, StringSplitOptions.RemoveEmptyEntries)
【讨论】: