double.NaN.ToString()以“¤¤¤”结尾不是预期的“NaN” [英] double.NaN.ToString() ending up "¤¤¤" not as Expected "NaN"

查看:87
本文介绍了double.NaN.ToString()以“¤¤¤”结尾不是预期的“NaN”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

double.NaN.ToString()以"¤¤¤"结尾不是预期的"NaN"为什么会这样?

double.NaN.ToString() ending up "¤¤¤" not as Expected "NaN" why is this?

在执行 

  System.Globalization.NumberFormatInfo numberFormatInfo =

    (System.Globalization.NumberFormatInfo)System.Globalization.NumberFormatInfo.CurrentInfo.Clone();

 System.Globalization.NumberFormatInfo numberFormatInfo =
    (System.Globalization.NumberFormatInfo)System.Globalization.NumberFormatInfo.CurrentInfo.Clone();

numberFormatInfo.NaNSymbol is "¤¤¤"

numberFormatInfo.NaNSymbol is "¤¤¤"

这是为什么?

// m

---系统-------------------------------- ---------------------------

--- System -----------------------------------------------------------

Windows 10(1709 16299.192),zh -Gb版本,国家或地区"瑞典",语言" Svensaka"

Windows 10 (1709 16299.192), en-Gb version, Country or region "Sweden", Language "Svensaka"

VisualStudio.15.Release / 15.5.5 + 27130.2026

Microsoft .NET框架

版本4.7.02556

VisualStudio.15.Release/15.5.5+27130.2026
Microsoft .NET Framework
Version 4.7.02556

---------------------- ----------------------------------------

--------------------------------------------------------------

moviestar

moviestar

推荐答案

这似乎表明你'使用没有语言包的语言。由于无法转换字符,因此使用替换字符。您上面发布的代码似乎只是您正在做的事情的一部分。由于您实际上并不是
更改任何值,因此克隆只是原始副本的副本。 这段代码打印出来的是什么?

That would seem to indicate you're using a language that doesn't have a language pack. Since the characters couldn't be converted it uses the replacement chars. The code you posted above seems like only a part of what you're doing. Since you're not actually changing any values the clone is just a copy of the original.  What does this code print out?

var result1 = Double.NaN.ToString();

var numberFormatInfo = System.Globalization.NumberFormatInfo.CurrentInfo.Clone() as System.Globalization.NumberFormatInfo;

var result2 = numberFormatInfo.NaNSymbol;




result1和result2应该相同。


result1 and result2 should be the same.


这篇关于double.NaN.ToString()以“¤¤¤”结尾不是预期的“NaN”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆