VB.Net: Generic OnTheFly mit Daten befüllen und dann direkt in ein Dictionary umwandeln

Auch mit VB.Net kann man Generische Kollektionen "on the fly", also direkt bei der Deklaration befüllen und auch direkt in ein Dictionary umwandeln:

'--"Normal" strong Typed List
Dim Ps As New List(Of Product)

'--Add Product :-o
Ps.Add(New Product With {.ID = "123", .Headline = "Test"})

'--Convert to Dictionary (see KeySelector!)
Dim Dict = Ps.ToDictionary(Function(c) c.ID)

gefunden hier:

http://blogs.msdn.com/timng/archive/2007/12/12/using-the-todictionary-extension-method.aspx

Comments

Add comment


 

  Country flag

biuquote
  • Comment
  • Preview
Loading