加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

vb.net – 将字符串拆分为对

发布时间:2020-12-17 07:28:23 所属栏目:百科 来源:网络整理
导读:我怎样才能在VB中将字符串拆分成双字母? 例如:abcdefgh 分成:ab cd ef gh 解决方法 我会把帽子扔进戒指: Dim test As String = "abcdefgh"Dim results As New List(Of String)For i As Integer = 0 To test.Length - 1 Step 2 If i + 1 test.Length Then
我怎样才能在VB中将字符串拆分成双字母?

例如:abcdefgh

分成:ab cd ef gh

解决方法

我会把帽子扔进戒指:

Dim test As String = "abcdefgh"
Dim results As New List(Of String)

For i As Integer = 0 To test.Length - 1 Step 2
  If i + 1 < test.Length Then
    results.Add(test.Substring(i,2))
  Else
    results.Add(test.Substring(i))
  End If
Next

MessageBox.Show(String.Join(" ",results.ToArray))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读