Defining different types of numbers in C#(在 C# 中定义不同类型的数字)
问题描述
您可以在 C# 中以多种方式定义数字,
You can define a number in various ways in C#,
1F // a float with the value 1
1L // a long with the value 1
1D // a double with the value 1
我个人正在寻找 short
,但是为了让这个问题成为人们更好的参考,您可以应用哪些其他数字文字的后缀?
personally I'm looking for which would a short
, however to make the question a better reference for people, what are all the other post-fix's to number literals you can apply?
推荐答案
Type Suffix .NET Framework Type
-------------------------------------------------------------------------------------
decimal M or m System.Decimal
double D or d System.Double
float F or f System.Single
int [1] System.Int32
long L or l System.Int64
[1] 当整数文字没有后缀时,它的类型是可以表示其值的类型中的第一个:int、uint、long、ulong.
[1] When an integer literal has no suffix, its type is the first of these types in which its value can be represented: int, uint, long, ulong.
当整数文字仅指定 U 或 u 后缀时,它的类型是这些类型中第一个可以表示其值的类型:uint、ulong.
When an integer literal specifies only a U or u suffix, its type is the first of these types in which its value can be represnted: uint, ulong.
当整数文字仅指定 L 或 l 后缀时,它的类型是这些类型中第一个可以表示其值的类型:long、ulong.
When an integer literal specifies only a L or l suffix, its type is the first of these types in which its value can be represnted: long, ulong.
当整数文字同时指定 U 或 u 和 L 或 l 后缀时,它的类型是这些类型中第一个可以表示其值的类型:ulong.
When an integer literal specifies both a U or u and L or l suffix, its type is the first of these types in which its value can be represnted: ulong.
这篇关于在 C# 中定义不同类型的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C# 中定义不同类型的数字
基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01