*** 如何将字符串转换为整型的数组***

CDEFGAB 2005-01-27 01:20:23
有字符串如下 :1 3 5 6 7 9

如何转成整型的数组呢

请用VB代码,谢谢
...全文
109 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjhphc 2005-01-27
  • 打赏
  • 举报
回复
Dim str As String = "12345"
Dim c() As Char = System.Text.Encoding.ASCII.GetChars(System.Text.Encoding.ASCII.GetBytes(str))
Dim result(c.Length - 1) As Integer
For i As Integer = 0 To c.Length - 1
result(i) = Integer.Parse(c(i))
Next
超级大笨狼 2005-01-27
  • 打赏
  • 举报
回复
用ArrayList多好啊。不用考虑长度和类型
Dim S As String
Dim result As New ArrayList()
For each S in Split("1 3 5 6 7 9")
result.Add(Convert.ToInt32(S))
Next

测试:
for i as integer = 0 to result.Count-1
Response.Write(result(i).GetType())
next
结果:
System.Int32System.Int32System.Int32System.Int32System.Int32System.Int32
saucer 2005-01-27
  • 打赏
  • 举报
回复
split it then convert them

dim s as string = "1 3 5 6 7 9"
dim slist() as string = s.Split(CChar(" "))
dim ilist(slist.Length -1) as integer

for i as integer = 0 to slist.Length - 1
ilist(i) = Convert.ToInt32(slist(i))
next
wj2929 2005-01-27
  • 打赏
  • 举报
回复
Dim str As String = "1 3 5 6 7 9"
Dim ary() As String
ary = str.Split(" "c)
Dim ary1(ary.Length - 1) As Int32
Dim i As Int32
For i = 0 To ary.Length
ary1(i) = Convert.ToInt32(ary(i))
Next

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧