OrderedDictionary.Contains メソッド
アセンブリ: System (system.dll 内)

Dim instance As OrderedDictionary Dim key As Object Dim returnValue As Boolean returnValue = instance.Contains(key)
戻り値
指定したキーを持つ要素が OrderedDictionary コレクションに格納されている場合は true。それ以外の場合は false。

Item プロパティを使用すると、キーが存在しない場合、またはキーが null 参照 (Visual Basic では Nothing) の場合に null 値を返すことができます。Contains メソッドを使用すると、特定のキーが OrderedDictionary コレクション内に存在するかどうかを確認できます。

OrderedDictionary コレクションの変更方法を示すコード例を次に示します。この例では、Contains メソッドを使用して、エントリを削除する前に、そのエントリが存在するかどうかを確認します。このコードは、OrderedDictionary で参照できるコード例の一部です。
' Modifying the OrderedDictionary If Not myOrderedDictionary.IsReadOnly Then ' Insert a new key to the beginning of the OrderedDictionary myOrderedDictionary.Insert(0, "insertedKey1", "insertedValue1") ' Modify the value of the entry with the key "testKey2" myOrderedDictionary("testKey2") = "modifiedValue" ' Remove the last entry from the OrderedDictionary: "testKey3" myOrderedDictionary.RemoveAt(myOrderedDictionary.Count - 1) ' Remove the "keyToDelete" entry, if it exists If (myOrderedDictionary.Contains("keyToDelete")) Then myOrderedDictionary.Remove("keyToDelete") End If End If
// Modifying the OrderedDictionary if (!myOrderedDictionary.IsReadOnly) { // Insert a new key to the beginning of the OrderedDictionary myOrderedDictionary.Insert(0, "insertedKey1", "insertedValue1"); // Modify the value of the entry with the key "testKey2" myOrderedDictionary["testKey2"] = "modifiedValue"; // Remove the last entry from the OrderedDictionary: "testKey3" myOrderedDictionary.RemoveAt(myOrderedDictionary.Count - 1); // Remove the "keyToDelete" entry, if it exists if (myOrderedDictionary.Contains("keyToDelete")) { myOrderedDictionary.Remove("keyToDelete"); } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- OrderedDictionary.Contains メソッドのページへのリンク