简体   繁体   English

怎么说C#中的数字是长或小数?

[英]How to say a number is a long or decimal in C#?

You can specify that a number is a double using the below code ('d' letter): 您可以使用以下代码('d'字母)指定数字是双精度数:

 double hi = 12d;

How to say a number is a long or decimal? 怎么说一个数字是长还是小数?

decimal dcml = 12?;
long lng = 12?;

The type suffix for long is L 长的类型后缀是L.
The type suffix for decimal is M 十进制的类型后缀是M.

decimal dcml = 12M;
long lng = 12L;

This is a simple article as a reference (simple meaning easier to read and digest, not simplistic) 这是一篇简单的文章作为参考(简单的意思是更容易阅读和消化,而不是简单化)
This is the reference for integers and for real numbers from the C# Language Specifications 这是 C#语言规范中的整数实数 的参考

Like this 像这样

decimal dcml = 12M;
long lng = 12L;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM