string.IsNullOrEmpty() vs string.NotNullOrEmpty()

前端 未结 14 1252
遇见更好的自我
遇见更好的自我 2021-02-01 02:56

I\'m curious if any developers use string.IsNullOrEmpty() more often with a negative than with a positive

e.g.

if (!string.IsNullOrEmpty())
14条回答
  •  忘掉有多难
    2021-02-01 03:53

    I've always thought it seemed the wrong way round as I use the negative much more often than the positive.

    I would also like there to be an instance IsEmpty() or IsNotEmpty() for use when the variable is declared within the function. This could not be IsNullOrEmpty() or IsNotNullOrEmpty() as if the instance was null then you would get a null reference exception.

提交回复
热议问题