如何在vb.net中添加到简单数组 [英] How do i add to a simple array in vb.net

查看:325
本文介绍了如何在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(",")

这篇关于如何在vb.net中添加到简单数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆