【发布时间】:2018-12-13 09:56:43
【问题描述】:
我尝试从字符串Data:[1,2,3] 中提取1,2,3 作为字符串。使用以下代码执行此操作会给我Error Index and length must refer to a location within the string,看起来我完全失明,但我看不出有什么问题。谁能帮帮我?
Sub Main()
Dim name As String = "Data:[1,2,3]"
Console.Write(name.Substring(6, name.Length - 1))
Console.Read()
End Sub
【问题讨论】:
-
您正在寻找
Console.Write(name.Substring(6, 5))。后一个数字是计数而不是索引。 -
Console.Write(Mid(name, 6))