Peristiwa
17 Mac, 9 PTG - 21 Mac, 10 PG
Sertai siri perjumpaan untuk membina penyelesaian AI berskala berdasarkan kes penggunaan dunia sebenar dengan rakan pembangun dan pakar.
Daftar sekarangPelayar ini tidak lagi disokong.
Naik taraf kepada Microsoft Edge untuk memanfaatkan ciri, kemas kini keselamatan dan sokongan teknikal yang terkini.
Introduces an Of
clause, which identifies a type parameter on a generic class, structure, interface, delegate, or procedure. For information on generic types, see Generic Types in Visual Basic.
The following code example uses the Of
keyword to define the outline of a class that takes two type parameters. It constrains the keyType
parameter by the IComparable interface, which means the consuming code must supply a type argument that implements IComparable. This is necessary so that the add
procedure can call the IComparable.CompareTo method. For more information on constraints, see Type List.
Public Class Dictionary(Of entryType, keyType As IComparable)
Public Sub add(ByVal e As entryType, ByVal k As keyType)
Dim dk As keyType
If k.CompareTo(dk) = 0 Then
End If
End Sub
Public Function find(ByVal k As keyType) As entryType
End Function
End Class
If you complete the preceding class definition, you can construct a variety of dictionary
classes from it. The types you supply to entryType
and keyType
determine what type of entry the class holds and what type of key it associates with each entry. Because of the constraint, you must supply to keyType
a type that implements IComparable.
The following code example creates an object that holds String
entries and associates an Integer
key with each one. Integer
implements IComparable and therefore satisfies the constraint on keyType
.
Dim d As New dictionary(Of String, Integer)
The Of
keyword can be used in these contexts:
.NET maklum balas
.NET ialah projek sumber terbuka. Pilih pautan untuk memberikan maklum balas:
Peristiwa
17 Mac, 9 PTG - 21 Mac, 10 PG
Sertai siri perjumpaan untuk membina penyelesaian AI berskala berdasarkan kes penggunaan dunia sebenar dengan rakan pembangun dan pakar.
Daftar sekarang