0

If I want use a decimal-literal in code, I use m-suffix, for example

decimal test = 1000m;

Is there any way to declare this m-suffix dynamically in run time? Somethings like this one:

decimal DeclareDecimal_M_SuffixFor(int decimalPoints)
{
    decimal result =  10 * decimalPoints m;
    return result;
} 
Masoud
  • 8,020
  • 12
  • 62
  • 123
  • Do you really need to do that in this function ? If you do, then just cast explicitly : `(decimal)decimalPoints` . But this case is useless. – Zein Makki Jul 20 '16 at 06:36

1 Answers1

1

No, decimalPoints m is invalid syntax - but you can use casting

decimal result =  10 * (decimal)decimalPoints;

or in this case better: a decimal multiplied with a int results into a decimal

decimal result =  10m * decimalPoints;
fubo
  • 44,811
  • 17
  • 103
  • 137