有没有把数以百万计成C#代码可读的方式吗? [英] Is there a readable way to put millions into c# code?
本文介绍了有没有把数以百万计成C#代码可读的方式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个有点难以阅读:
INT X =亿;
有没有简单的方法来写:
INT X =亿;
这样的规模是显而易见的?
<块引用>
普莱舍注意这不是输出格式。
块引用>
解决方案
有没有简单的方法来写
亿
块引用>
否。这是不可能把逗号的数字。
逗号和其他类似的东西是演示的需要。如果你担心代码的可读性,然后要么宣布与名称常量像
百万
,TEN_MILLIONS
等,或干脆命名该变量来表示值。This is a little hard to read:
int x = 100000000;
Is there any easy way to write:
int x = 100,000,000;
So that the scale is obvious?
Plese note this is NOT about formatting for output.
解决方案Is there any easy way to write
100,000,000
No. It is not possible to put commas in numeric.
Comma and other similar things are for presentation purpose. If you are worried about code readability then either declare constants with name like
MILLION
,TEN_MILLIONS
etc or simply name the variable to represent value.这篇关于有没有把数以百万计成C#代码可读的方式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文