public class MyClass
{
public const Decimal CONSTANT = 0.50; // ERROR CS0664
}
produces this error:
error CS0664: Literal of type double cannot be implicitly converted to type 'decimal'; use an 'M' suffix to create a literal of this type
as documented. But this works:
public class MyClass
{
public const Decimal CONSTANT = 50; // OK
}
And I wonder why they forbid the first one. It seems weird to me.
See Question&Answers more detail:os