gpt4 book ai didi

.net ToString() 格式文档

转载 作者:行者123 更新时间:2023-12-04 01:39:04 25 4
gpt4 key购买 nike

前几天我看到一个代码片段,它将 bool 值转换为相应的"is"/“否”值:

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

代码工作正常,但我很好奇它是如何工作的,我无法在 MSDN documentation for ToString() 中找到答案。 .

任何人都可以对此有所了解吗?

最佳答案

它把它当作 Custom Numeric Format String .具体参见链接页面中关于节分隔符的部分:

The ';' character is used to separate sections for positive, negative, and zero numbers in the format string. If there are two sections in the custom format string, the leftmost section defines the formatting of positive and zero numbers, while the rightmost section defines the formatting of negative numbers. If there are three sections, the leftmost section defines the formatting of positive numbers, the middle section defines the formatting of negative numbers, and the rightmost section defines the formatting of zero numbers.

关于.net ToString() 格式文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/521079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com