For I’ve tried this:
Dim exampleItems As Dictionary(Of String, String) = New Dictionary(Of String, String)
Dim blah = exampleItems.Select (Function(x) New (x.Key, x.Value)).ToList 'error here
But I’m getting a syntax error and all the examples that I’ve seen are in C#.
This would be:
For details, see Anonymous Types. (Depending on usage, you might also want Key or Value to be flagged with the Key keyword.)
That being said,
Dictionary(Of TKey, Of TValue)already is anIEnumerable(Of KeyValuePair(Of TKey, Of TValue), so you can also just do:And you’ll have a list of KeyValuePair, which has a
KeyandValueproperty already. This really means there’s no need to make the anonymous type.