本文整理匯總了VB.NET中System.Collections.Generic.Dictionary<TKey,TValue>.Add方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Dictionary<TKey,TValue>.Add方法的具體用法?VB.NET Dictionary<TKey,TValue>.Add怎麽用?VB.NET Dictionary<TKey,TValue>.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Collections.Generic.Dictionary<TKey,TValue>
的用法示例。
在下文中一共展示了Dictionary<TKey,TValue>.Add方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Dictionary
' Create a new dictionary of strings, with string keys.
'
Dim openWith As New Dictionary(Of String, String)
' Add some elements to the dictionary. There are no
' duplicate keys, but some of the values are duplicates.
openWith.Add("txt", "notepad.exe")
openWith.Add("bmp", "paint.exe")
openWith.Add("dib", "paint.exe")
openWith.Add("rtf", "wordpad.exe")
' The Add method throws an exception if the new key is
' already in the dictionary.
Try
openWith.Add("txt", "winword.exe")
Catch
Console.WriteLine("An element with Key = ""txt"" already exists.")
End Try