c# - Whats the best way to format this number? -


I have double and I want to format it with the following rules:

  • If there is no decimal place, show only the number (see 100 examples below)
  • Shows 2 decimal places if there is a decimal place < P> Then, as a few examples:
      100 - & gt; 100 99.958443534 - & gt; 99.96 99.1 - & gt; 99.10    

    You can use:

      Decimal a = 99.9 4 9 99 99 99 M; Mathematics.Round (A, 2); // Returns 99.95    

  • Comments

    Popular posts from this blog

    mysql - BLOB/TEXT column 'value' used in key specification without a key length -

    c# - Using Vici cool Storage with monodroid -

    python - referencing a variable in another function? -