0

I was wondering if there's a way to create a dictionary using an anonymous type for its values. Something like

{
    { "first",  {1, true} },
    { "second", {2, false} },
}

I want to use this in .NET 3.5, so there's no vanilla implementation of Tuple<...> available.

Any suggestions?

Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233
  • 1
    Possible duplicate with http://stackoverflow.com/questions/1619518/a-dictionary-where-value-is-an-anonymous-type-in-c – Branimir Sep 28 '10 at 14:00

1 Answers1

0

What I generally use (though this is ugly and assumptive) is:

Dim dict As Dictionary(Of String, Object())
dict.Add("first", New Object() {1, true})
dict.Add("second", New Object() {2, false})

Obviously, this doesn't provide the compiler support for type- and bounds-checking your tuples, but in a pinch it works.