In the following code
//add to bool or double Dictionary
this.m_unit.Add((unittype == "b")? unitnum:(double)unitnum);
The bool dictionary uses an integer index, the double uses a double
index, which some may take issue with, but that's a different
discussion. The problem is that unitnum is always cast to a double, even
when unittype is "b". That seems like a bug to me.
If I change it to
this.m_unit.Add((unittype == "d")? (double)unitnum:unitnum);
it still always casts it to a double. I'm annoyed that the ternary
operator always casts unitnum to a double.
(parenthetical discussion)
The object is to later be able to set values, like so
//1234 is a bool
Grp.Unit[1234] = true;
//4321 is a double
Grp.Unit[4321d] = 1.0;
//there is also a uint index for conversion between bool and double
//set bool from double
Grp.Unit[1234u] = 1.0;
//set double from bool
double myvalue = Grp.Unit[1234u];
but, like I said, that's not the discussion I want to have. There is a
lot of code, and it minimizes it, especially when dealing with
bool-to-double conversions.
*** Sent via Developersdex http://www.developersdex.com ***