
The System Namespace | 103
.NET FCL
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
The System.Array Class
The System.Array class contains useful methods for dealing with arrays. For
instance, it has a Sort method that sorts the elements of an array. The following
block of code uses Array.Sort to order a list of
Integer values.
Public Sub SortArray( )
' ----- Simple array sorting example.
Dim counter As Integer
Dim dataToFix( ) As Integer = {9, 8, 12, 4, 5}
' ----- First, show the world the mixed-up mess.
Console.WriteLine("Unsorted:")
For counter = 0 To 4
Console.WriteLine(CStr(dataToFix(counter)))
Next counter
' ----- Yeah! I don't have to Bubble sort by myself.
Array.Sort(dataToFix)
' ----- Display the correct results.
Console.WriteLine("Sorted:")
For counter = 0 To 4
Console.WriteLine(dataToFix(counter))
Table 7-1. Members of the System.Convert class
Method VB equivalent Description
ToBoolean CBool
Converts a value to Boolean
ToByte CByte
Converts a value to an unsigned 8-bit integer Byte
ToChar CChar
Converts a value to a single character Char
ToDateTime CDate
Converts a value to date or time value DateTime (Date in
Visual Basic)
ToDecimal CDec
Converts a value to a floating point Decimal
ToDouble CDbl
Converts a value to a floating point Double
ToInt16 CShort
Converts a value to a signed 16-bit integer Int16 (Short in
Visual Basic)