Nate  Peters

Nate Peters

  • NA
  • 2
  • 33.7k

C# dictionary with multiple values

Jul 15 2011 12:04 PM

I am using a C# dictionary.

Dictionary<int, string> d = new Dictionary<int, string>();

I am using the dictionary as then I can have the key value be unique and is enforced by the Dictionary.

The key value will be int. Before I had the need of only one value. Now things have expanded to where I need to store multiple values(with different data types) for the same key.

Something like this - (although it will not work):

Dictionary<int,string,string,bool, bool,int,bool> d = new Dictionary<int, string,string,bool, bool,int,bool>();


Note that string,string,bool, bool,int,bool are additional values I like to store for the key field which will be an int.

I am not sure how I would go about doing this. How can I get a key value to store multiple values with different data types. On Way that I see that this may be possible is to store the additional fields into a List but not sure how it will all come togehter. If somebody can provide and example that would be appreciated.

Thanks in advance.


Answers (5)