I am using an online convert tool to convert the VB Codes to C#. The VB codes are:
Private Const constant1 As Decimal = CDec(37.5)
result:
private const decimal constant1 = Convert.ToDecimal(37.5);
However, there is an error message when compiling:
The expression being assigned to 'constant1' must be constant
In order to remove the error, I amended the codes as:
private const decimal constant1 = (decimal)37.5;
Can anyone advise why the Convert.ToDecimal couldn't return a Constant?