检查 false 布尔条件时不是关键字 vs = False [英] Not keyword vs = False when checking for false boolean condition
本文介绍了检查 false 布尔条件时不是关键字 vs = False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用 If 语句并且我想检查布尔值是否为 false 时,我应该使用Not"关键字还是只是 = false,就像这样
When I'm using an If statement and I want to check if a boolean is false should I use the "Not" keyword or just = false, like so
If (Not myboolean) then
对比
If (myboolean = False) then
哪种做法更好,更易读?
Which is better practice and more readable?
推荐答案
当然,使用Not".对于交替,使用If (myboolean)"而不是If (myboolean = true)"
Definitely, use "Not". And for the alternately, use "If (myboolean)" instead of "If (myboolean = true)"
如果你给布尔值一个可读的名字效果最好:
The works best if you give the boolean a readable name:
if (node.HasChildren)
这篇关于检查 false 布尔条件时不是关键字 vs = False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文