Hi all,
I had a simple c# format that need your help
My code is as follow:
Yield = (float
)Good/(float)(Total);sw.WriteLine(Total + "\t\t\t" + Good + "\t\t\t" + Yield);
My question is how to format Yield to 2 decimal places.
Yield is declared as a double.
Thanks

convert double to 2 decimal places
dnzone
Hi all,
Thanks for your help. I got it.
nadir
hi,
double dbValue=11.11111111;
string sValue=string.
Format("{0:#,###0.00}",dbValue);then sValue will have the value 11.11
Big5824
This is how you can do it
double d = 11.313243432d; string s = d.ToString("f2");HTH
qrli
Math
.Roundmoondaddy
Well, let's fix you other problem as well:
Yield = (float)Good/(float)(Total);
sw.WriteLine("{0:f2}\t\t\t{1:###0.00}\t\t\t{2:f2}", Total,Good, Yield);
In each {...} case the number before the colon is the postion among the other parameters, and the text after the colon is the format. I gave it two different ways, but each works the same.