问题描述
有谁知道C#编译器数量文字修饰的完整列表?
在默认情况下,宣布0使一个Int32和'0.0'使它成为双师型。我可以用文字修饰'F'末,以确保一些被视为'单'代替。例如像这样...
VAR X = 0; // x是的Int32
变种Y = 0F; // y是单
什么是其他修饰符可以使用吗?是否有一个强制为双,小数,UInt32的?我尝试使用Google的这一点,但无法找到任何东西。也许我的术语是错误的,那么这可以解释为什么我来了空白。任何帮助非常AP preciated。
变种Y = 0F; // f是单
变种Z = 0D; // z是双
变种R =0米; // r是小数
VAR I = 0U; //我为unsigned int
变种J = 0L; // j是长(注:为清楚起见资本L)
VAR K = 0UL; // k是无符号长(为清楚起见注资L)
从整数文字2.4.4.3与真正的文字。需注意,L和UL是pferred,而不是他们的清晰度小写变种$ P $所推荐的
Does anyone know the full list of C# compiler number literal modifiers?
By default declaring '0' makes it an Int32 and '0.0' makes it a 'Double'. I can use the literal modifier 'f' at the end to ensure something is treated as a 'Single' instead. For example like this...
var x = 0; // x is Int32
var y = 0f; // y is Single
What are the other modifiers I can use? Is there one for forcing to Double, Decimal, UInt32? I tried googling for this but could not find anything. Maybe my terminology is wrong and so that explains why I am coming up blank. Any help much appreciated.
var y = 0f; // f is single
var z = 0d; // z is double
var r = 0m; // r is decimal
var i = 0U; // i is unsigned int
var j = 0L; // j is long (note capital L for clarity)
var k = 0UL; // k is unsigned long (note capital L for clarity)
From the C# specification 2.4.4.2 Integer literals and 2.4.4.3 Real literals. Take note that L and UL are preferred as opposed to their lowercase variants for clarity as recommended by Jon Skeet.
这篇关于C#编译器数量文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!