Този браузър вече не се поддържа.
Надстройте до Microsoft Edge, за да се възползвате от най-новите функции, актуализации на защитата и техническа поддръжка.
To sort a string array, why is it important to use the String.Trim() method on each array element before sorting?
String.Trim()
Only string arrays with elements trimmed with String.Trim() can sort.
String.Trim() removes leading white space that would sort before numbers and letters.
The array sort is noticeably faster using String.Trim() on each element.
Both foreach and for are good choices to iterate small single dimension arrays like {"cat", "fox", "dog", "snake", "eagle"}, but when is it best to use a for loop?
foreach
for
When the elements have alphabetical sort order.
To perform a search on each element in the array.
To evaluate a specific range of elements.
You must answer all questions before checking your work.
Тази страница полезна ли беше?
Нуждаете се от помощ по тази тема?
Искате ли да опитате да използвате Ask Learn, за да изясните или да ви насочи по тази тема?