# Assigning Values

• ### Question

• Hi everyone,

I'd like to know how to assign more than one value to a value without each value equaling each other.

For example:

a = b  and  a = c   and  a=d   but b does not equal c or d and c does not equal d. Can someone help?

Thanks
Sunday, June 22, 2008 1:42 PM

• What you want is mathematically impossible, but maybe you're asking the wrong question. Perhaps you need 'a' to be a collection; that way it can have multiple values. Like so:

Or you can use a hashtable / dictionary to use a lookup by name:

 int b, c, d; Dictionary a = new Dictionary(); a["b"] = b; a["c"] = c; a["d"] = d;

Or maybe what you need is to access b, c and d through a in a type safe manner:

 class A { public int B { get; set; } public int C { get; set; } public int D { get; set; } } A a = new A { B = 1, C = 2, D = 3 }; // Now you can access b, c and d through a. int x = a.B + a.C + a.D;

I hope this helps.
• Marked as answer by Wednesday, June 25, 2008 6:27 AM
Sunday, June 22, 2008 2:27 PM