G
Guest
I have a method that passes in two string objects (both numerical numbers)
and a string identifying their type.
public bool DoCompare(string num1, string num2, string theirType)
{
System.Type type = System.Type.GetType(theirType);
return ((type)num1 <= (type)num2) ? true : false;
}
The compiler doesn't like the (type) casting that I do. What is the proper
way of casting an object to its correct type to do such a mathematical
operation?
and a string identifying their type.
public bool DoCompare(string num1, string num2, string theirType)
{
System.Type type = System.Type.GetType(theirType);
return ((type)num1 <= (type)num2) ? true : false;
}
The compiler doesn't like the (type) casting that I do. What is the proper
way of casting an object to its correct type to do such a mathematical
operation?