I have a simple conversion of a decimal
in C#. It looks like this:
private decimal BaseValue
{
get; set;
}
public decimal ConvertedValue
{
get
{
return BaseValue * (365 / 360);
}
}
However, this does not work. I assume because C# is processeing the numbers in the fraction as integers. So I can do like this instead (which works):
public decimal ConvertedValue
{
get
{
return BaseValue * (decimal)((double)365 / (double)360);
}
}
Now this seems a bit like overkill, but I can live with that. My primary question is this:
Why does Visual Studio warn me that 'Cast is redundant', for the
(double)
cast? And if I remove the(double)
cast, then the(decimal)
cast becomes redundant. And if I remove that, then I am back to the solution, which does not work. Help...?