Searches for a key : ListDictionary « Data Structure « VB.Net






Searches for a key

 

Imports System
Imports System.Collections
Imports System.Collections.Specialized

Public Class SamplesListDictionary   
   Public Shared Sub Main()
      Dim myCol As New ListDictionary()
      myCol.Add("A", "a")
      myCol.Add("B", "b")
      myCol.Add("C", "c")

      Dim myArr(myCol.Count) As DictionaryEntry
      myCol.CopyTo(myArr, 0)

      If myCol.Contains("A") Then
         Console.WriteLine("The collection contains the key ""Kiwis"".")
      Else
         Console.WriteLine("The collection does not contain the key ""Kiwis"".")
      End If

   End Sub 'Main



End Class 

   
  








Related examples in the same category

1.Display the contents of the collection using For Each. This is the preferred method
2.Display the contents of the collection using the enumerator
3.Display the contents of the collection using the Keys, Values, Count, and Item properties