如何在vb.net中添加到简单数组
问题描述:
如果我有
Dim a As String()=( One,Two)。Split(,)
如何添加到该字符串?
答
最简单的方法是将其转换为列表,然后添加。
The easiest way is to convert it to a List and then add.
Dim a As List(Of String) = ("One,Two").Split(",").ToList
a.Add("Three")
或是否真的要保留数组。
or if you really want to keep an array.
Dim a As String() = ("One,Two").Split(",")
Dim b as List(Of String) = a.ToList
b.Add("Three")
a=b.ToArray
这实际上是框外的东西:
And here is something really outside the box:
a = (String.Join(",", a) & ",Three").Split(",")