Hallo,
Is it possible to cast from an object to an other type where the type is unknown at compile time?
Something like this
int orgValue = 10;
object obj = orgValue;
int final = (obj.GetType())obj;
If it is possible it would save me from typing up a very long and ugly if-statement.
Edit:
The reason for wanting to do this is that my api has a function that can take a lot of different variables as input. I want to store the data I want to pass in, but in order to pass them to this function I need to convert the data back to its original data type(its all int, float, double, bool, string)
The function:
void ApiFunction(int input)
void ApiFunction(float input)
...
What I want to do:
ApiFunction( (obj.GetType())obj )
Thanks,



LinkBack URL
About LinkBacks



