如何将字符串转换为数组?
值以字符串形式传递:
Dim strInput as string
strInput = "Tom, John, Jason, Mike"
Run Code Online (Sandbox Code Playgroud)
我的错误信息是: Value of type 'String' cannot be converted to 'System.Array'
Mat*_*att 13
Dim source As String = "Tom, John, Jason, Mike"
Dim stringSeparators() As String = {","}
Dim result() As String
result = source.Split(stringSeparators, _
StringSplitOptions.RemoveEmptyEntries)
Run Code Online (Sandbox Code Playgroud)
或者使用Microsoft.VisualBasic.Strings.Split:
Dim source As String = "Tom, John, Jason, Mike"
Dim result() As String = Split(source, ",")
Run Code Online (Sandbox Code Playgroud)