Click here to Skip to main content
15,040,212 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,
I have a situation where i have both numeric and decimals... For example

7 should be converted to 7.00
10 should be converted to 10.00
54.43 should be as 54.43

please give a best solution to convert into above format as a string..... it will be better if u use any cultre info... in c#
Posted

It will be better if you try checking the documentation[^] first.
   
Comments
Rahul VB 30-Jan-14 23:42pm
   
5!
You can use ToString, it is faster.
C#
Int32 num1 = 7;
UInt16 num2 = 10;
double num3 = 54.53;
string str1 = num1.ToString("0.00");
string str2 = num2.ToString("0.00");
string str3 = num3.ToString("0.00");
   
v2
Comments
Karthik_Mahalingam 30-Jan-14 18:40pm
   
5
S Houghtelin 3-Feb-14 9:18am
   
Thank you :)
Rahul VB 30-Jan-14 23:42pm
   
5!
S Houghtelin 3-Feb-14 9:18am
   
Thank you :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900