Data Type Suffixes (Numeric Literals) in C#

2010-09-03


Maybe you need to check .NET Data Type Suffixes, or call it Numeric Literals.

For example: 100L means long type, then what meaning of 100M ?

The following is all data type suffixes which I have found:

Type Suffix .NET Framework Type
long L or l System.Int64
decimal M or m System.Decimal
double D or d System.Double
float F or f System.Single
int [1] System.Int32
Type Suffix Example
uint U or u 50U
long L or l 50L
ulong UL or ul 50UL
float F or f 23.45F
decimal M or m 12.34M

(by the way: using 0x such as 0x100 means the number '100' is Hexadecimal)

float ff = 23.56; // error !! float ff = 23.56f; //OK

If you want to know how the suffix will be in VB.net, please visit this site: UnderMyHat, you will get more information for not only C# data suffixes but also for VB !