views:

21

answers:

1

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?

A: 

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.

Sehrgut