public static bool CanCast(InnerType fType, InnerType sType, bool bothCases = true) { if (fType == sType) { return(true); } if (fType is NumericType && sType is NumericType) { NumericType toC = (NumericType)sType; NumericType fromC = (NumericType)fType; if (bothCases) { if (fromC.CanCast(toC) || toC.CanCast(fromC)) { return(true); } } else if (fromC.CanCast(toC)) { return(true); } return(false); } else { return(false); } }
public static InnerType HigherPriorityType(InnerType ftype, InnerType stype) { if (ftype is NumericType && stype is NumericType) { NumericType ftypeC = (NumericType)ftype; NumericType stypeC = (NumericType)stype; if (ftypeC.CanCast(stypeC)) { return(stypeC); } else { return(ftypeC); } } else { return(null); } }