C# - Numeric Suffixes

Jim B picture Jim B · Aug 25, 2010 · Viewed 20k times · Source

Possible Duplicate:
Declaration suffix for decimal type

Hey everyone,

In the following snippet of code; RewardValue is a decimal:

dto.RewardValue = 1.5;

Now, this gives me the following error:

"Cannot convert source type double to target type decimal"

Makes sense, and is easily fixable by changing that line of code to this:

dto.RewardValue = 1.5m;

Now, the "m" converts that to a decimal and all is good.

Does anybody know of somewhere where I could find a list of all those "m" type operators? (and if you could let me know what the proper term for those are, it would be greatly appreciated)

EDIT: Thanks to HCL and MartyIX for letting me know that these are referred to as "suffixes"

Answer

Adam Robinson picture Adam Robinson · Aug 25, 2010

I believe the term you're looking for is "suffix".

Examples:

1;    // int
1.0;  // double
1.0f; // float
1.0m; // decimal
1u;   // uint
1L;   // long
1UL;  // ulong