2010-07-21 3 views
2

est-il possible de faire la même chose dans VB.NET?Comment remplir Dictionary (Of TKey, TValue) directement dans VB.NET

Dictionary<int, string> myDict = new Dictionary<int, string>()  
{   
    { 2, "This" },  
    { 1, "is" },   
    { 5, "radio" },  
    { 12, "clash" },  
}; 
+4

Même question ici http://stackoverflow.com/questions/318530/is-it-possible-to-initialise-a-new-system -collections-generic-dictionary-with-str Vérifiez la réponse de jgauffin. Voici un exemple: 'Dim myDic comme nouveau dictionnaire (Of Integer, String) De {{1," One "}, {2," Two "}}'. Ceci est seulement pour VB.NET 10 –

Répondre

8

Comme indiqué dans le commentaire de Marcel ci-dessus:

Dim myDict As New Dictionary(Of Integer, String) From _ 
     {{1, "one"}, {2, "two"}, {3, "three"}} 
Questions connexes