gpt4 book ai didi

vb.net - 将字符串拆分成对

转载 作者:行者123 更新时间:2023-12-04 16:55:18 27 4
gpt4 key购买 nike

我将如何继续在 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))

关于vb.net - 将字符串拆分成对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8138571/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com