Convert.ToString()相关问题 [英] Convert.ToString() Related issue

查看:98
本文介绍了Convert.ToString()相关问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我有一个双倍的值,如1.0;



现在我'我试图把它转换成字符串...这里我需要相同的1.0字符串...而不是1.0我得到1 ...请帮助我..提前感谢:-)



double value = 1.0;

string strvalue = Convert.ToString(value);



这里我'得到strvalue为1



但转换成字符串后我需要获得1.0 ...



帮我..

Dear all,

I have a value in double like 1.0;

Now I'm trying to convert it into string ... Here i need the same 1.0 in string... Instead 1.0 i'm getting 1... Please help me.. Thanks in advance :-)

double value = 1.0;
string strvalue = Convert.ToString(value);

Here I'm getting strvalue as 1

but i need to get 1.0 once after converting to string...

Help me ..

推荐答案

你好,



看看这里:

http://stackoverflow.com/a/8039032 [ ^ ]

所以,试试:

Hi,

Have a look here:
http://stackoverflow.com/a/8039032[^]
So, try:
string strvalue = value.ToString(".0###############");


尝试:

Try:
double value = 1.0;
string s = value.ToString("0.0");


尝试:



double value = 1.0;

string strvalue = value.ToString(f1);
Try:

double value = 1.0;
string strvalue = value.ToString("f1");


这篇关于Convert.ToString()相关问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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