title: Digit grouping with two decimal places in c#
body: <p>I want to display a number which is of double datatype in C#, in grouped digits and with two decimal places only if it contains a decimal no.</p>
  
  <p>e.g. If there is 2000.4567 and 2000.45, it must be displayed as 2,000.45 and if it is 2000 then it will displayed as 2,000 (grouped but without decimal).</p>
  
  <p>I have tried this and it is working fine for digit grouping but it rounds off the decimal no. to an integer value either by floor or ceil:</p>
  
  <pre><code>DimensionLength.ToString("#,##0")
  </code></pre>
  
  <p>DimensionLength is of type double.</p>