“Not … Is Nothing” versus “… IsNot Nothing”

前端 未结 5 1637
夕颜
夕颜 2020-12-29 03:33

Does anyone here use VB.NET and have a strong preference for or against using Not foo Is Nothing as opposed to foo IsNot Nothing? If so, why?

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 03:41

    Using VB 7.0

    If var1 Is Not Nothing Then

    generates an "invalid use of object error" as per this "VBForums" link.

    If var1 IsNot Nothing Then

    generates a "Compile error: Expected: Then or GoTo"

    If Not IsNothing(var1) Then

    worked like a champ

提交回复
热议问题