查看这个号码的问题? 2.050.000 [英] Problem with view this number ? 2.050.000

查看:133
本文介绍了查看这个号码的问题? 2.050.000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我有这个号码2.050.000它没有在表格中显示我使用浮动

第二个点2.050的问题这没关系但这个2.050.000不行吗?

数字如65.233工作正常,但这个数字没有显示

有没有我可以用来使它工作的数据类型?



我尝试了什么:



i尝试bigint但不起作用

hello i have this number 2.050.000 its not showing in table i use float
the problem with the second dot 2.050 this is ok but this 2.050.000 will not work ?
numbers like 65.233 is working ok but this number is not showing
is there any datatype i can use to make it work??

What I have tried:

i tried bigint but didn't work

推荐答案

问题在于,对于C#而言,2.050.000不是一个数字。

虽然'。'被允许作为几种语言的千位分隔符,但C#根本不使用它们,并坚持将数字写成nnnnnn.dddd,其中nnnnnn是整数部分,dddd是小数部分。

所以如果你的数字应该是2050000然后把它写成2050000.0。

如果你有用户输入的值包含千位分隔符,那么使用double.TryParse来转换它:



double d;

string userInput =2,050,000; //我的Locale使用逗号分隔符

if(!double.TryParse(userInput,out d))

{

Console.WriteLine( 不承认);

}

其他

{

Console.WriteLine(d);

}



如果用户Locale设置正确,则应以所需方式解析输入。
The trouble is that "2.050.000" is not a number as far as C# is concerned.
Although '.' is allowed as a "thousands separator" in several languages, C# does not use them at all, and insists that a number is written as "nnnnnn.dddd" where "nnnnnn" is the integer part, and "dddd" is the "fractional" part.
So if you number should be 2050000 then write it as 2050000.0.
If you have user entered values that include a thousands separator, then use double.TryParse to convert it:

double d;
string userInput = "2,050,000"; // My Locale uses a comma separator
if (!double.TryParse(userInput, out d))
{
Console.WriteLine("Not recognised");
}
else
{
Console.WriteLine(d);
}

Provided the user Locale is set correctly, that should parse the input in the desired fashion.


这篇关于查看这个号码的问题? 2.050.000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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