Dictionary with 2 Values

studio

#1

Is is possible to have 2 values for one name?
So
Name Value1 Value2

I need this for selection a template.
First I check if an EmailFrom contains a specific @…
Which is specified in the configfile and thus thus received in dictionary.
From this same Config file I will receive the template name for this.

So it should be handy when Dictionary can have 2 values.


#2

Hi,

Yes you can have two values for one Key, try to have your dictionary as per the below syntax,

Dictionary(Of String, IEnumerable(Of String))


#3

Hi here @marbroer,
Definitely, as noted by @sarathi125, you can include a collection within the entry value.

This could be an Array, List, or an IEnumerable (for example), as stated above.

Thanks in advance,
Josh


#4

Ok, that is great, and how do I refer to the second or third value?


#5

In your case better option use Dictionary(Of String, Tuple(Of String, String)).

dict = New Dictionary(Of String, Tuple(Of String, String)() From { {“key1”, Tuple.Create(“Value1”, “Value2”)}, {“key2”, Tuple.Create(“Value3”, “Value4”)} }

to get value back:
dict(“key1”).Item1 - return “Value1”,
dict(“key1”).Item2 return “Value2”