c# - string.IsNullOrEmpty() 与 string.NotNullOrEmpty()

标签 c# .net string

我很好奇是否有开发人员更频繁地使用 string.IsNullOrEmpty() 来表示否定而不是表示

例如

if (!string.IsNullOrEmpty())

这就是我 99% 的时间使用该方法的方式。对此的设计决定是什么?

最佳答案

因为“IsNullOrEmpty”比“NotNullOrEmpty”更容易理解。后者可以解释为:

  1. 不为空,也不为空
  2. 不为空或为空

关于c# - string.IsNullOrEmpty() 与 string.NotNullOrEmpty(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/734372/

相关文章:

.net - WCF UriTemplate 不会匹配带有斜杠(/)的单个字符串参数

c# - WPF:如何在 Key* 事件中检测 Key 重复?

c# - 使用变量代替函数名

java - 创建包含分隔符的 on split 方法

java - int不能转换成字符串?

javascript - 如何在字符串中出现的两个字符之间插入一个字符?

c# - 如何在 C# 中从 Datatable 动态构建插入命令

c# - 如何覆盖 Web Services .Net 中的 Wsdl 生成

c# - C#中的NotifyIcon.ShowBalloonTip可以自定义吗?

c# - 如何在 Asp.Net MVC 4 中模拟 HttpContext.User.Identity.Name