vb.net怎么把一个string字符串转换成string数组

比如dim a as string = "abc"dim b as string()然后把A的ABC分别输入到B(0)B(1)B(2)
2024-11-16 01:51:18
推荐回答(4个)
回答1:

 dim a as string="a,b,c"
 dim b()as string 
b=split(a,",")

回答2:

for i = 1 to Len(a)
b(i - 1) = Mid(a, i, 1)
Next

结果:
b(0) = "a"
b(1) = "b"
b(2) = "c"

回答3:

Dim a As String = "abc"
Dim b As String()
ReDim b(a.Length)
For i = 1 To a.Length
b(i - 1) = Mid(a, i, 1)
Next

回答4:

符合VB.NET习惯的转换方式如下:

Dim a As String = "abc"
Dim b() As String
Dim c() As Char = a.ToCharArray()
Dim i As Integer
ReDim b(a.Length - 1)
For i = 0 To a.Length - 1
b(i) = c(i).ToString
Next