本文介绍了如何使用vb.net将一个字符串值放入数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

如何使用VB.Net将字符串值添加到数组变量中?



Ex:



dim txt as string

dim strArray()as string

txt = sample



我想要的数组把文本样本放在下面的方式。



strArray(0)= s

strArray(2)= a

strArray(3)= m

strArray(4)= p

strArray(5)= l

strArray(6 )= e

How to add a string value into array variable using VB.Net?

Ex:

dim txt as string
dim strArray() as string
txt=sample

in array i want to put that text "sample" in following way.

strArray(0)=s
strArray(2)=a
strArray(3)=m
strArray(4)=p
strArray(5)=l
strArray(6)=e

推荐答案


Public Shared Function ToStrArray(ByVal value As String) As String()
    Dim result As String() = New String(value.Length - 1) {}
    For i As Integer = 0 To value.Length - 1
        result(i) = New String(value(i), 1)
    Next
    Return result
End Function



示例:


Example:

Dim strArray() as string = ToStrArray("sample")


<pre lang="vb">


这篇关于如何使用vb.net将一个字符串值放入数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 23:13