mike

mike

  • NA
  • 3
  • 0

dictionary in a dictionary

Jan 1 2009 11:36 AM

Hi,

I'm new in C#. I'm trying to find a method to have an "easy" access to my customers, example:

allCustomers[44][Name]   ->  gives me the name of the customer no 44
allCustomers[30][Age]     ->  gives me the age of the customer no 33

allCustomers is constructed as follows:

int customerNo  = 44;
string name        = "Gates";
string prename   = "Bill";
int age               = 30;
float revenue     = 234.234F

Dictionary<int, Dictionary<string, string>> allCustomers = new Dictionary<int, Dictionary<string, string>>();
Dictionary<string, string> customer = new Dictionary<string, string>();

allCustomers.Add(CustomerNo, customer.Add("Name", name);
allCustomers.Add(CustomerNo, customer.Add("Prename ", prename );
allCustomers.Add(CustomerNo, customer.Add("Age", age.ToString());
allCustomers.Add(CustomerNo, customer.Add("Revenue ", revenueToString());

My problem now is, that I have to convert all variables into string and vice versa, for example "age"

Question: Is there a better way/design to solve this problem ?

I would be very thankful if I could get as many suggestions.

thanks mike


Answers (2)