title: c# How do I format a double to a string and only show decimal digits when necessary?
body: <p>I found this question in StackOverFlow but it didn't solve my problem.
  <a href="https://stackoverflow.com/questions/3243440/how-do-i-format-a-double-to-a-string-and-only-show-decimal-digits-when-necessary">How do I format a double to a string and only show decimal digits when necessary?</a></p>
  
  <pre><code>Weight
  
  0.500
  18.000
  430.000
  </code></pre>
  
  <p>by the solution in above url my result show in this form:</p>
  
  <pre><code>Weight
  
  0.5 
  18
  430
  </code></pre>
  
  <p>and my problem is in decimal digits, I want show decimal digits in 3 digit,like this:</p>
  
  <pre><code>Weight
  
  0.500   
  18
  430
  </code></pre>