ΥڡϤƤʥ֥åޡɲΥڡޤϤƤʥ֥åޡ Υڡlivedoor åפɲΥڡޤlivedoor å

ܼ

ǤΤʤ

ξǿ˥ޥʥͤȡ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
 
    '¤ΥȤ¹ԡʥоݤName
    Private Sub sortStructure(ByVal structList() As struct, _
                  ByRef newStructList() As struct)
        '¤¤ΤArrayListѴ
        Dim ar As ArrayList = New ArrayList()
        For Each tmpStruct As struct In structList
            ar.Add(tmpStruct)
        Next
 
        'ArrayListΥȤ¹Ԥ
        ar.Sort(New nameCompare)
 
        '¤ΤArrayList鹽¤Ѵ
        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