Using the Of Keyword
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 System.
IComparable.CompareTo method.
For more information on constraints, see Type List.
Ofキーワードの使い方について
次のコード例はOfキーワードを使っているが、それは二つのタイプのパラメータを取るクラスの外形を定義している。
IComparableインターフェースのKeyTypeパラメータを含むが、ここで使われるコードにはIComparableを実装した引数を
あてなくてはならないということを意味する。これが必要なのはadd関数がシステムをコールのIComarable.CompareToを実行
できるようにするためである。さらに詳しくは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
VB.NET質問スレ(Part43) [無断転載禁止]©2ch.net
■ このスレッドは過去ログ倉庫に格納されています
667デフォルトの名無しさん
2017/08/12(土) 22:39:38.37ID:QjNv8My6■ このスレッドは過去ログ倉庫に格納されています
