Q:

formatting double precision values in C#

Say I have a double variable initialized as 
double dValue  = 5.156365

I would like to show this in a textbox as 5.16 i.e only two decimal places.
How should I format? 
Is textbox.Text = dValue.ToString("F2", Culture.....) correct? When I tried it did give me the correct result.  However, if dValue = 5 then I would like only 5 to be shown and not 5.00.
How could I achieve this in C#?

A:

A 0 in the string forces that decimal place, while a # lets the number get up to that decimal place.
   dValue.ToString("0.##")

