How do i display a number in float values.

Posted by Mahe under C# on 9/4/2012 | Points: 10 | Views : 1093 | Status : [Member] | Replies : 4
Hi

How do i display a number in float values.
ex: 123 as 123.00

Regards,
Mahe




Responses

Posted by: Ranjeet_8 on: 9/4/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Try this
 

string Cint = String.Format("{0:0.00}", 123);


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

Posted by: Maheshvishnu on: 9/4/2012 [Member] Starter | Points: 25

Up
0
Down
int num=123;
int numInDouble=(double)num;
Console.WriteLine(numInDouble);

mahesh

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

Posted by: Pgayath on: 9/4/2012 [Member] Starter | Points: 25

Up
0
Down
Mahe,

The following are the various ways to do it.

1. String.Format("{0:0.00}", 123)
2. String.Format("{0:#,##0.00;(#,##0.00);Zero}", 123) ----> Outputs even for the negative number and if no value outputs "Zero"
3. 123.ToString("####0.00")
4. 123.ToString("0.00")
5. 123.ToString("N2")

Thanks,
Gayathri P

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

Posted by: Vikash on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
nice example thanks..............

Regards,
Vikash Pathak

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

Login to post response