A dictionary is a key-value pair, where the value is fetched depending on the key. The keys are all unique.
Now if you want a Dictionary
with 1 keytype and multiple value types, you have a few options:
first is to use a Tuple
var dict = new Dictionary>()
The other is to use (with C# 4.0 and above):
var dict = new Dictionary()
the System.Dynamic.ExpandoObject
can have value of any type.
using System;
using System.Linq;
using System.Collections.Generic;
public class Test {
public static void Main(string[] args) {
dynamic d1 = new System.Dynamic.ExpandoObject();
var dict = new Dictionary();
dict[1] = d1;
dict[1].FooBar = "Aniket";
Console.WriteLine(dict[1].FooBar);
dict[1].FooBar = new {s1="Hello", s2="World", s3=10};
Console.WriteLine(dict[1].FooBar.s1);
Console.WriteLine(dict[1].FooBar.s3);
}
}