R
Ray Mitchell
Hello,
I have an array list whose elements are the following
types:
float
int
float
int
....etc.
I have the following code dealing with the elements:
float f0 = (float)list[0];
float f1 = (float)list[1];
float f2 = (float)list[2];
float f3 = (float)list[3];
Although the code compiles fine, I get a "Specified cast
is not valid." runtime exception on f1 and f3. I can fix
it by doing the following:
float f1 = (float)(int)list[1];
float f3 = (float)(int)list[3];
However, that's rediculous since in reality my code is a
loop that merely does something like:
for (i = 0; i < list.Count; ++i)
floatArray = (float)list;
What's going on?
Thanks,
Ray Mitchell
I have an array list whose elements are the following
types:
float
int
float
int
....etc.
I have the following code dealing with the elements:
float f0 = (float)list[0];
float f1 = (float)list[1];
float f2 = (float)list[2];
float f3 = (float)list[3];
Although the code compiles fine, I get a "Specified cast
is not valid." runtime exception on f1 and f3. I can fix
it by doing the following:
float f1 = (float)(int)list[1];
float f3 = (float)(int)list[3];
However, that's rediculous since in reality my code is a
loop that merely does something like:
for (i = 0; i < list.Count; ++i)
floatArray = (float)list;
What's going on?
Thanks,
Ray Mitchell