How to display decimal value in Label

Posted by Deysomnath under ASP.NET on 8/30/2011 | Points: 10 | Views : 15097 | Status : [Member] | Replies : 2
double result;
result = 123.00;
Label2.Text = result.ToString("N2");




Responses

Posted by: Deysomnath on: 8/30/2011 [Member] Starter | Points: 25

Up
0
Down
N2 --> for 2 decimal (ex. 123.00)
N3 --> for 3 decimal (ex. 123.000)
N4 --> for 4 decimal (ex. 123.0000)
..........
..........
so on..

Deysomnath, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 8/30/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,
Thanks for your sharing.

Same thing will happen to using 'F'

double result = 123;
Label2.Text = result.ToString("F4");
Result: 123.0000

If using 'E' instead of 'F' means its consider as exponential.
Result: 1.2300E+002

Thanks,
T.Saravanan

Deysomnath, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response