31

i have three double variable a ,b and c

a = 0.000006 
b = 6 
c = a/b;

so C should be 0.000001

i want to show this value in text box so i wrote

textbox.text = c.tostring();

but it's give result as "1E-06"..

Can anybody help me out how can i put correct value in textbox ?

Thanks

Ed S.
  • 122,712
  • 22
  • 185
  • 265
Kartik
  • 611
  • 5
  • 17
  • 31
  • Possible duplicate of [Double to string conversion without scientific notation](http://stackoverflow.com/questions/1546113/double-to-string-conversion-without-scientific-notation) – GSerg Nov 02 '16 at 10:06

2 Answers2

48
a = 0.000006;
b = 6;
c = a/b;

textbox.Text = c.ToString("0.000000");

As you requested:

textbox.Text = c.ToString("0.######");

This will only display out to the 6th decimal place if there are 6 decimals to display.

bluish
  • 26,356
  • 27
  • 122
  • 180
Adam Davis
  • 91,931
  • 60
  • 264
  • 330
20

Try c.ToString("F6");

(For a full explanation of numeric formatting, see MSDN)

Jim Arnold
  • 2,238
  • 14
  • 18