C# short/long/int literal format?

3Dave picture 3Dave · Apr 28, 2011 · Viewed 80.7k times · Source

In C / C# / etc. you can tell the compiler that a literal number is not what it appears to be (ie., float instead of double, unsigned long instead of int:

var d = 1.0; // double
var f = 1.0f; // float
var u = 1UL; // unsigned long

etc.

Could someone point me to a list of these? I'm specifically looking for a suffix for short or Int16.

Answer

Thomas Levesque picture Thomas Levesque · Apr 28, 2011
var d  = 1.0d;  // double
var d0 = 1.0;   // double
var d1 = 1e+3;  // double
var d2 = 1e-3;  // double
var f  = 1.0f;  // float
var m  = 1.0m;  // decimal
var i  = 1;     // int
var ui = 1U;    // uint
var ul = 1UL;   // ulong
var l  = 1L;    // long

I think that's all... there are no literal specifiers for short/ushort/byte/sbyte