Can I get cast operators via reflection and invoke (or if there's a better name for that action) them? That's the main question, if yes, it solves my problem.
But if someone knows another solution to the following:
I have many object vars (unknown quantities until runtime), each one have a different type, but all of them are numbers (double, int, short).
On the other hand, I've got the same number of double vars, and need to compare values each to each.
object[] Value1; //this can be double, short or int, only known at runtime.
double[] Value2;
//I need simply to do:
(for int i = 0; i < Value1.Length, i++)
{
(if Value1[i] == Value2[i]) //here's the problem
//the comparison always return false, because of different types
....
I've tryed many things, including the "CompareTo" method invoked via reflection, but it demands that de object vars are of the same type of the instance containing the method invoked. (Cannot call from a double and pass an int parameter, nor call from int and pass a double parameter)
So, if I could just cast them: One way is from double to the unknown type (for that I'd have to use some reflection) The other way is a two step casting from object to the unknown type, and from that to double.
Limitations:
dynamic is not an option (old framework)
Value1 items come individually "as object" from an external unchangeable method.