我想要一种简洁的方式来输出 bool 值?在 C# 中。目前,我正在做这个非常笨重的事情。
string outputString = boolValNullable.HasValue && boolValNullable.Value ? "true" : "false";
我想做这样的事情:
string outputString = boolValNullable ?? "null"
以上是无效语法。
最佳答案
string output = boolValNullable?.ToString() ?? "null"
关于c# - 如何输出以控制 bool 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60456886/