数字后面的字母,叫什么?

Letter after a number, what is it called?(数字后面的字母,叫什么?)
本文介绍了数字后面的字母,叫什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这叫什么?

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

我在哪里可以找到我可以使用的字符的参考?如果我想将 0 转换为 short,我需要哪个字母?

And where can I find a reference of characters I can use? If I want to cast 0 to short, which letter I need?

推荐答案

最好的来源是 C# 规范,特别是 文字.

The best source is the C# specification, specifically section Literals.

相关位:

整数字面量的类型确定如下:

The type of an integer literal is determined as follows:

  • 如果字面量没有后缀,则它具有可以表示其值的以下类型中的第一个:intuintlong, ulong.
  • 如果文字以 U 或 u 为后缀,则它具有可以表示其值的以下类型中的第一个:uintulong.
  • 如果文字以 L 或 l 为后缀,则它具有以下类型中的第一个可以表示其值:longulong.
  • 如果文字以 UL、Ul、uL、ul、LU、Lu、lU 或 lu 为后缀,则为 ulong 类型.
  • If the literal has no suffix, it has the first of these types in which its value can be represented: int, uint, long, ulong.
  • If the literal is suffixed by U or u, it has the first of these types in which its value can be represented: uint, ulong.
  • If the literal is suffixed by L or l, it has the first of these types in which its value can be represented: long, ulong.
  • If the literal is suffixed by UL, Ul, uL, ul, LU, Lu, lU, or lu, it is of type ulong.

如果没有指定real_type_suffix,那么真实字面量的类型是double.否则,实数类型后缀决定实数字面量的类型,如下:

If no real_type_suffix is specified, the type of the real literal is double. Otherwise, the real type suffix determines the type of the real literal, as follows:

  • 以 F 或 f 为后缀的实数是 float 类型.[…]

以 D 或 d 为后缀的实数是 double 类型.[…]

A real literal suffixed by D or d is of type double. […]

以 M 或 m 为后缀的实数是 decimal 类型.[…]

A real literal suffixed by M or m is of type decimal. […]

这意味着字母(或字母)被称为后缀".short 是没有办法用这种方式表示的,所以只能用 (short)0,或者只用 short x = 0;.

That means the letter (or letters) is called "suffix". There is no way to represent short this way, so you have to use (short)0, or just short x = 0;.

这篇关于数字后面的字母,叫什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)