public static string toString(object thisObj) { if (!Convert.IsString(thisObj)) { throw new JScriptException(JSError.StringExpected); } else { return(Convert.ToString(thisObj)); } }
public object EvaluatePlus(object v1, object v2) { object val1 = Convert.ToPrimitive(v1, null); object val2 = Convert.ToPrimitive(v2, null); if (Convert.IsString(val1) || Convert.IsString(val2)) { return(Convert.ToString(val1) + Convert.ToString(val2)); } else { return(Convert.ToNumber(val1) + Convert.ToNumber(val2)); } }
public static double JScriptCompare(object v1, object v2) { object p1 = Convert.ToPrimitive(v1, null); object p2 = Convert.ToPrimitive(v2, null); if (Convert.IsString(p1) && Convert.IsString(p2)) { string s1 = Convert.ToString(p1); string s2 = Convert.ToString(p2); return(s1.CompareTo(s2)); } else { double n1 = Convert.ToNumber(p1); double n2 = Convert.ToNumber(p2); return(n1 - n2); } }