双转换为字符串 [英] Convert double to string

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

问题描述

我有三个双变量a,b和c

  A = 0.000006 
B = 6
C = A / b;



所以C应为0.000001



我要显示文本框中这个值,所以我写了

  textbox.text = c.tostring(); 



但它给出的结果是1E-06..



任何人都可以帮我我怎么可以把文本框中正确的值?



感谢


解决方案

  A = 0.000006; 
B = 6;
C = A / B;

textbox.Text = c.ToString(0.000000);



根据你的要求:

  textbox.Text = c.ToString(0 ######); 

这将只显示出到第6位小数,如果有6位小数显示。


i have three double variable a ,b and c

a = 0.000006 
b = 6 
c = a/b;

so C should be 0.000001

i want to show this value in text box so i wrote

textbox.text = c.tostring();

but it's give result as "1E-06"..

Can anybody help me out how can i put correct value in textbox ?

Thanks

解决方案

a = 0.000006;
b = 6;
c = a/b;

textbox.Text = c.ToString("0.000000");

As you requested:

textbox.Text = c.ToString("0.######");

This will only display out to the 6th decimal place if there are 6 decimals to display.

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

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