Item property throws an exception if the requested key is not in the dictionary
Imports System Imports System.Collections.Generic Public Class Example Public Shared Sub Main() Dim openWith As New SortedDictionary(Of String, String) openWith.Add("A", "a") openWith.Add("B", "b") openWith.Add("C", "c") openWith.Add("D", "d") Try Console.WriteLine("For key = ""tif"", value = {0}.", openWith("tif")) Catch Console.WriteLine("Key = ""tif"" is not found.") End Try End Sub End Class