【发布时间】:2010-10-05 13:29:19
【问题描述】:
我正在用 VS2008 编写 VB.NET。
我有一个逗号分隔的数字字符串,即 16,7,99,1456,1,3
我在 VB 中这样做:
Dim MyArr() As String = MyString.Split(",")
MyArr 会按照它们在字符串中的顺序保留项目吗?
如果我这样做:
For Each S as String in MyString.Split(",")
'Do something with S
'Will my items be in the same order they were
'in the string?
Next
我对其进行了测试,它似乎保持了排序顺序,但它会~总是~保持顺序吗?
如果它不保持顺序,那么拆分字符串并保持顺序的好方法是什么?
我之所以问,是因为 MSDN 数组文档说:“数组不能保证被排序。”所以我有点不确定。
【问题讨论】:
标签: vb.net arrays string sorting