Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>"00" is not a special case, just an example, although the way it is worded makes it sound like a special case. </p> <p>From the documentation:</p> <blockquote> <p>The "0" custom format specifier serves as a zero-placeholder symbol. If the value that is being formatted has a digit in the position where the zero appears in the format string, that digit is copied to the result string; otherwise, a zero appears in the result string. The position of the leftmost zero before the decimal point and the rightmost zero after the decimal point determines the range of digits that are always present in the result string.</p> </blockquote> <p>So ToString("00") means you will have a <em>minimum</em> of two digits to the left of the decimal point, and NO digits to the right of the decimal point (those get rounded). Likewise, ToString("000") will give you a minimum of 3 digits, and so on. </p> <p>You can also control the <em>exact</em> number of digits that will appear to the right of the decimal point. ToString("000.00") will give you at least 3 digits to the left of the decimal point, and exactly 2 digits to the right. Any extra digits to the right of the decimal point will be rounded.</p> <p>Here are some passing assertions to demonstrate:</p> <pre><code>var value = 67.89; Assert.AreEqual("68", value.ToString("0")); Assert.AreEqual("68", value.ToString("00")); Assert.AreEqual("068", value.ToString("000")); Assert.AreEqual("067.9", value.ToString("000.0")); Assert.AreEqual("067.89", value.ToString("000.00")); Assert.AreEqual("067.890", value.ToString("000.000")); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload