Letter after a number, what is it called?

后端 未结 5 1267
无人及你
无人及你 2020-12-10 01:53

What is this called?

double  d1 = 0d;
decimal d2 = 0L;
float   d3 = 0f;

And where can I find a reference of characters I can use? If I want

5条回答
  •  天涯浪人
    2020-12-10 02:05

    This

    double  d1 = 0d;
    

    is an example of a literal and the character after the digits is a suffix. There is not one for short. You need to cast:

    short s = (short)0;
    

    These are defined in 2.4.4 of the language specification, specifically 2.4.4.2 will tell you about integer literals where you will see that there is no way to express a short using a literal. Additionally, the integer-type-suffixes are:

    U  u  L  l  UL  Ul  uL  ul  LU  Lu  lU  lu
    

    which represent various signed/unsigned int/long types. Again, no way to express a short using literal.

提交回复
热议问题