[英]vb.net: how do I add a vb.net form as an attachment to an existing program?
[英]How do i add to a simple array in vb.net
如果我有
Dim a As String() = ("One,Two").Split(",")
如何添加到該字符串?
最簡單的方法是將其轉換為列表,然后添加。
Dim a As List(Of String) = ("One,Two").Split(",").ToList
a.Add("Three")
或者如果您真的想保留一個數組。
Dim a As String() = ("One,Two").Split(",")
Dim b as List(Of String) = a.ToList
b.Add("Three")
a=b.ToArray
這實際上是框外的東西:
a = (String.Join(",", a) & ",Three").Split(",")
對於其他方法,請嘗試:
Dim a As String() = ("One,Two").Split(CChar(","))
Debug.Print(CStr(UBound(a)))
ReDim Preserve a(9)
Debug.Print(CStr(UBound(a)))
即時窗口的輸出為:
1
9
注意:由於我始終使用Option Strict On
不允許使用隱式轉換),因此我不得不稍微更改您的原始行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.