Mega Code Archive

 
Categories / VB.Net / Data Structure
 

ListDictionary Contains Method tells whether the ListDictionary contains a specific 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")       PrintKeysAndValues(myCol)       If myCol.Contains("Kiwis") 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    Public Shared Sub PrintKeysAndValues(myCol As IDictionary)       Dim de As DictionaryEntry       For Each de In  myCol          Console.WriteLine("   {0,-25} {1}", de.Key, de.Value)       Next de    End Sub  End Class