On Wed, 14 Mar 2007 10:42:58 -0400, Wynn Rostek wrote:
In C# is there any way to do formatted printing like there is in C? In C, I
would do sprintf(string, "%4.2f",floatvalue) to print a float value with two
decimal places. I have looked around a bit, but have not run across anything
like this in C#, maybe I am just missing something.
Many thanks,
Wynn
All native types have a ToString() method, that has an overload that takes
format strings. What you want to investigate is the various format strings
available. For instance
double f =0;
Console.Write(f.ToString("n"));
Will do what you want
--
Bits.Bytes
http://bytes.thinkersroom.com