jjzjj

IsNullOrWhiteSpace

全部标签

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

在.NET4.0及更高版本中存在string.IsNullOrWhiteSpace(string)时,在检查字符串时使用string.IsNullOrEmpty(string)是否被视为不良做法? 最佳答案 最佳做法是选择最合适的。.NetFramework4.0Beta2hasanewIsNullOrWhiteSpace()methodforstringswhichgeneralizestheIsNullOrEmpty()methodtoalsoincludeotherwhitespacebesidesemptystring.Th

javascript - JavaScript 中的“IsNullOrWhitespace”?

是否有等同于.NET的String.IsNullOrWhitespace的JavaScript以便我可以检查客户端的文本框是否包含任何可见文本?我宁愿先在客户端执行此操作,也不愿回发文本框值并仅依赖服务器端验证,尽管我也会这样做。 最佳答案 对于简洁的现代跨浏览器实现,只需执行以下操作:functionisNullOrWhitespace(input){return!input||!input.trim();}这是jsFiddle.注释如下。currentlyacceptedanswer可以简化为:functionisNullOrW
12