ǤΤʤ †
ξǿ˥ޥʥͤȡLength0¨ǤΤʤ롣
Dim i As Integer = 0
Dim a(i - 1) As String
UBoundؿξ¤ֹ롣UboundؿǤΤʤꤹ-1֤롣
[]Ca[i]Сǥå0i-1iĤǤǤꡢVB.NETȰۤʤ롣ˡCǤiޥʥˤ뤳ȤϤǤʤ
CopyToåɤǡ켡Τ٤ƤǤԡλꥤǥåϰ֤Ȥƥԡ뤳ȤǤ롣
ԡ.CopyTo(ԡ,ϰ)
¤Υ †
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| | Private Class nameCompare : Implements System.Collections.IComparer
Public Function Compare(ByVal right As Object, _
ByVal left As Object) _
As Integer Implements IComparer.Compare
Return ((CType(right, struct)).Name).CompareTo((CType(left, struct)).Name)
End Function
End Class
Public Class TestClass
Private Structure struct
Dim Code As String
Dim Name As String
End Structure
Private Sub sortStructure(ByVal structList() As struct, _
ByRef newStructList() As struct)
Dim ar As ArrayList = New ArrayList()
For Each tmpStruct As struct In structList
ar.Add(tmpStruct)
Next
ar.Sort(New nameCompare)
Dim tmpStuctList(UBound(structList)) As struct
Dim i As Integer = 0
For Each st As struct In as
With tmpStructList(i)
.Code = ar.Code
.Name = ar.Name
End With
i += 1
Next
NewStructList = tmpStructList
End Sub
End Class
|
- إϤWindowsץߥVisual Basic 2008