29

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.
  • 119,398
  • 20
  • 176
  • 254
Kartik
  • 591
  • 5
  • 15
  • 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

47
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
  • 24,718
  • 26
  • 114
  • 174
Adam Davis
  • 89,812
  • 58
  • 259
  • 331
17

Try c.ToString("F6");

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

Jim Arnold
  • 2,148
  • 13
  • 19