C# Casting to a decimal
.net, c#, casting, decimal, double
Solution
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)`.
Problem
What, if any, is the difference between? ``` decimal d = (decimal) myDouble; decimal d = new decimal(myDouble); decimal d = Convert.ToDecimal(myDouble); ```