Search code examples
c#literalslanguage-specifications

C# short/long/int literal format?


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.


Solution

  • 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