在我的网站上,我有一个文本框,允许用户输入一组数字,如下所示:
(118,38,137,15,156,14,157,36,152,49,142,57)
Run Code Online (Sandbox Code Playgroud)
如何将这些数字存储在如下数组中?:
[118 38 137 15 156 14 157 36 152 49 142 57]
Run Code Online (Sandbox Code Playgroud)
使用Split方法:
yourString = yourString.Substring(1, yourString.Length - 2) ' Trim parentheses.
Dim result As String() = yourString.Split(","c)
Run Code Online (Sandbox Code Playgroud)
Split根据目的,该方法有几个重载.我选择了最简单的,只需要一个Character参数,在本例","c中是一个逗号.