0

我需要接受这个字符串:

Dim tmpTry As String = "10, 20, 30, 40, 50, 52, 20, 20, 10, 35, 3, 8, 47, 7, 2, 5, 55, 8, 0, 0, 6, 55, 0, 2, 12, 0, 0, 21, 14, 0, 3"

并将其转换为双数组:

Dim arrNumOfVisits As Double() = New Double(tmpTry) {}

我该怎么做呢?

仅供参考 arrNumOfVisits 进入ParamArray System.Collections.IEnumerable()

大卫

4

1 回答 1

2
Dim arrString As String() = tmpTry.Split(New Char() {" "C})
Dim arrNumOfVisits As Double() = New Double(arrString.Length) {}
Dim i As Integer = 0
While i < arrString.Length
    arrNumOfVisits(i) = Double.Parse(arrString(i))
    i += 1
End While

上面的代码可以解决问题,在此使用 regEx 将是矫枉过正。

尽量学习基本的 RegEx 操作,这里是我最喜欢的备忘单: http ://regexlib.com/CheatSheet.aspx?AspxAutoDetectCookieSupport=1
http://www.cheatography.com/davechild/cheat-sheets/常用表达/

于 2012-04-18T06:09:24.247 回答