C# Casting to a decimal
问题 What, if any, is the difference between? decimal d = (decimal) myDouble; decimal d = new decimal(myDouble); decimal d = Convert.ToDecimal(myDouble); 回答1: There is no difference. If you look at the source: In Decimal: public static explicit operator decimal(double value) { return new decimal(value); } In Convert: public static decimal ToDecimal(float value) { return (decimal) value; } So in the end they all call new decimal(double) . 回答2: They all achieve the same results. However, here's a