为什么这个奇怪的转换双重字符串发生? [英] Why this wierd convert double to string happens?

查看:59
本文介绍了为什么这个奇怪的转换双重字符串发生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

why this wierd convert double to string happens?







I使用win 8.1,视觉工作室2019在笔记本电脑中很奇怪。

i使用win 10,视觉工作室2019在PC中就可以了。



我尝试过:






I use win 8.1 ,visual studio 2019 in laptop it is wierd.
i use win 10 , visual studio 2019 in PC and it is ok.

What I have tried:

double d=1.2;
string sWierd =""+d;//s=1/2
string sOk=d.ToString();//s=1.2

//both are not "1.2" for me so that is weird.
//weird one is "1/2". it changes dot to foreslash

推荐答案

在波斯语中,斜杠是小数点分隔符



十进制分隔符 - 维基百科 [ ^ ]



我的猜测是一种方法正在使用你的locale和另一个不是,出于某种原因?
In Persian, a slash is a decimal separator

Decimal separator - Wikipedia[^]

My guess would be that one method is using your locale and the other is not, for some reason?


你在说什么怪异?没有什么奇怪的事情发生。这两个字符串都是1.2。



如果你在谈论这样做:

What are you talking "weird"? There's nothing weird going on. Both strings are "1.2".

If you're talking about doing this:
string sWeird = "" + d;



并想知道为什么它正在工作,这是因为.ToString()被隐式调用 d 使表达式 string.Empty + d 工作。


这篇关于为什么这个奇怪的转换双重字符串发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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