Šī pārlūkprogramma vairs netiek atbalstīta.
Jauniniet uz Microsoft Edge, lai izmantotu jaunāko līdzekļu, drošības atjauninājumu un tehniskā atbalsta sniegtās priekšrocības.
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.
Vai šī lapa palīdzēja?
Vai nepieciešama palīdzība saistībā ar šo tēmu?
Vai vēlaties izmēģināt lietotni Ask Learn, lai noskaidrotu vai palīdzētu jums apgūt šo tēmu?