.net ToString() format documentation

后端 未结 5 1439
感情败类
感情败类 2021-02-20 08:06

I saw a code snippet the other day that converts a Boolean value to the corresponding \"Yes\"/\"No\" value:

CDbl(True).ToString(\"Yes;Yes;No\")

5条回答
  •  爱一瞬间的悲伤
    2021-02-20 08:56

    It's using the literal format string from the customized numeric format strings. You can supply a literal that maps onto numbes that are postive, negative, or zero numbers. The first "yes" maps to positive, the second to negative, and the "no" to zeros. Thus any non-zero is yes, and only zeros are no. This is equivalent to standard true/false semantic interpretations on numeric values.

    Look under "section separator" of the Custom Numeric Format strings page.

提交回复
热议问题