IsNothing versus Is Nothing

后端 未结 9 1511
暗喜
暗喜 2020-11-29 23:51

Does anyone here use VB.NET and have a strong preference for or against using IsNothing as opposed to Is Nothing (for example, If IsNothing(a

9条回答
  •  一整个雨季
    2020-11-30 00:02

    If you take a look at the MSIL as it's being executed you'll see that it doesn't compile down to the exact same code. When you use IsNothing() it actually makes a call to that method as opposed to just evaluating the expression.

    The reason I would tend to lean towards using "Is Nothing" is when I'm negating it becomes "IsNot Nothing' rather than "Not IsNothing(object)" which I personally feel looks more readable.

提交回复
热议问题