|
|
Sorting an array - .Net
|
Views : 267
|
|
Tagged in : .Net
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
Arrays that consist of elements that implement the IComparable interface can be sorted using the Sort() method via the following syntax: Array.Sort(ArrayName)
Example:
Sub Page_Load(sender as Object, e as EventArgs)
Dim randNumbers(10) as Integer
Dim i as Integer
Dim rndNum as New Random()
For i = 0 to 10
randNumbers(i) = rndNum.Next(100)
Next i
' Display the random numbers
randNumDisplay.DataSource = randNumbers
randNumDisplay.DataBind()
' Sort the array
Array.Sort(randNumbers)
' Display the sorted array
orderedNumDisplay.DataSource = randNumbers
orderedNumDisplay.DataBind()
End Sub
|
|
By banumathi, On - 2011-03-15 |
|
|
|