gpt4 book ai didi

c# - 如何将 bool true 或 false 转换为字符串 "True"或 "False"

转载 作者:太空狗 更新时间:2023-10-29 18:03:37 26 4
gpt4 key购买 nike

有没有一种简单的方法可以将 bool true 或 false 转换为字符串“True”或“False”。我知道我可以用一些 if 逻辑来做到这一点,但我想知道是否有更简单的东西。

最佳答案

Boolean结构有一个 ToString() 方法。所以:

bool b = true;
Console.WriteLine(b.ToString());

关于c# - 如何将 bool true 或 false 转换为字符串 "True"或 "False",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6433622/

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