5
A
回答
8
根據ILSpy在string.Split
的內部顯示的內容,回答是是。
private string[] InternalSplitKeepEmptyEntries(
int[] sepList, int[] lengthList, int numReplaces, int count)
{
int num = 0;
int num2 = 0;
count--;
int num3 = (numReplaces < count) ? numReplaces : count;
string[] array = new string[num3 + 1];
int num4 = 0;
while (num4 < num3 && num < this.Length)
{
array[num2++] = this.Substring(num, sepList[num4] - num);
num = sepList[num4] + ((lengthList == null) ? 1 : lengthList[num4]);
num4++;
}
if (num < this.Length && num3 >= 0)
{
array[num2] = this.Substring(num);
}
else
{
if (num2 == num3)
{
array[num2] = string.Empty;
}
}
return array;
}
所有元件(例如,array
變量)按升序排列經常被加工和不排序發生。
MSDN documentation for string.Split
也列出了一些例子,其結果與原始字符串中的順序相同。
由於Jim Mischel指出上面,這只是目前的實施,這可能會改變。
+4
堅實的證明。還有不錯的速度。 – captncraig
1
是的。否則,這將是無用的。
相關問題
- 1. F#Async.Parallel結果保證按順序嗎?
- 2. Java中的String.split()保證返回一個有序數組嗎?
- 3. string.split,但保持順序匹配
- 4. 保留SOAP結果的排序順序
- 5. 無法順序結果時正確分組
- 6. shuffle()數組..正確的方法來隨機化數組結果?
- 7. 如何保持MySQL結果的順序?
- 8. foreach%dopar% - 保證結果的順序?
- 9. 保留數組的順序
- 10. SQL:得到正確的結果順序
- 11. async.map保證結果是按順序傳遞的嗎?
- 12. 密碼:如何確保結果列表的順序?
- 13. 確保UDP中的數據包順序
- 14. 如何確保方法按正確的順序執行?
- 15. String.Split()的奇怪結果
- 16. 不使用String.Split方法拆分字符串不會返回正確的結果
- 17. 確定DOM順序確定表單參數的順序嗎?
- 18. MySQL的:順序分組結果由ID
- 19. Angular.js - 順序列表,並保存結果
- 20. 在PHP中保證關聯數組的順序嗎?
- 21. string.split('/')沒有給出正確的數組
- 22. VB.NET String.Split方法?
- 23. 排序無序的SQL結果基於原始數組順序
- 24. 我可以確保組件安裝順序嗎?
- 25. 總數加數的順序會影響結果嗎?
- 26. PHP str_replace:數組中的元素順序和輸出結果
- 27. 保存方法和結果
- 28. mysql_num_rows結果順序
- 29. apply_async結果順序
- 30. thinking_sphinx結果順序
現在我認爲它會是的 – V4Vendetta
你有一個很好的答案,並且可能是我們所能期待的最好的答案。不過,我必須指出,只是因爲當前的實施將事情按照預期的順序進行,這不是一個真正的保證。也就是說,BCL團隊改變訂單是愚蠢的。它只是沒有任何意義。 –
感謝您的有用評論吉姆。無論如何改變String.Split中的順序是不太可能的,可能最好避免從split方法中獲得一致的順序。 – iburlakov