Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

easy way to format numbers to strings?

Status
Not open for further replies.

thedougster

Programmer
Jan 22, 2009
56
US
In C#, I'd like to convert some numbers to strings in a standard format, but preferably in a simple way, such as if you were going to output them rather than store them in string variables, a la:
Code:
Console.WriteLine ("{0:F2}", num);
rather than use a bunch of string methods to make them all the same number of significant digits. Isn't there any way to do this?
 
Does
Code:
String.Format("{0:0.00", num)

Count as a lot string methods? THat one will give you two decimal places.

[small]----signature below----[/small]
The author of the monograph, a native of Schenectady, New York, was said by some to have had the highest I.Q. of all the war criminals who were made to face a death by hanging. So it goes.

My Crummy Web Page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top