我怎样才能让下面的代码返回 False
如果usable
是True
以外的任何东西(除 bool
以外的任何内容),目前我的代码抛出异常 usable
不是 boolean 值。
if (!Boolean.Parse(readValue("Useable"))) return true;
return (defined.ContainsKey(key) || (key == "Useable"));
最佳答案
bool isUseable;
bool.TryParse(readValue("Useable"), out isUseable);
关于c# - 如果变量不是 boolean 值则返回 False,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1465937/