如何:在 Visual Basic 中排序陣列How to: sort an array in Visual Basic

本文說明如何在 Visual Basic 中排序字串陣列的範例。This article shows an example of how to sort an array of strings in Visual Basic.

範例Example

這個範例會宣告名為 zooAnimals 的 @no__t 0 物件陣列,填入它,然後依字母順序排序:This example declares an array of String objects named zooAnimals, populates it, and then sorts it alphabetically:

Private Sub SortAnimals()
    Dim zooAnimals(2) As String
    zooAnimals(0) = "lion"
    zooAnimals(1) = "turtle"
    zooAnimals(2) = "ostrich"
    Array.Sort(zooAnimals)
End Sub

穩固程式設計Robust programming

以下條件可能會造成例外狀況:The following conditions may cause an exception:

另請參閱See also