我正在研究 Project Euler 40,并且是有点困扰,没有 int.Parse(char)
.没什么大不了的,但我做了一些询问,有人建议使用 char.GetNumericValue
.GetNumericValue
对我来说似乎是一个非常奇怪的方法:
I was working on Project Euler 40, and was a bit bothered that there was no int.Parse(char)
. Not a big deal, but I did some asking around and someone suggested char.GetNumericValue
. GetNumericValue
seems like a very odd method to me:
那么这种方法背后的原因是什么,返回双重服务的目的是什么?我什至启动了 Reflector 并查看了 InternalGetNumericValue
,但这就像在看 Lost:每个答案都会导致另一个问题.
So what's the reasoning behind this method, and what purpose does returning a double serve? I even fired up Reflector and looked at InternalGetNumericValue
, but it's just like watching Lost: every answer just leads to another question.
请记住,它采用 Unicode 字符并返回一个值.'0' 到 '9' 是标准的十进制数字,但还有其他 Unicode 字符表示数字,其中一些是浮点数.
Remember that it's taking a Unicode character and returning a value. '0' through '9' are the standard decimal digits, however there are other Unicode characters that represent numbers, some of which are floating point.
喜欢这个角色:
Console.WriteLine( char.GetNumericValue( '' ) );
在控制台窗口中输出 0.25.
Outputs 0.25 in the console window.
这篇关于char.GetNumericValue 是怎么回事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!