写空或空的更简单的方法? [英] Easier way of writing null or empty?
本文介绍了写空或空的更简单的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我敢肯定,我错过了一些东西在这里。具有一定的项目,我需要检查,如果字符串为空或null。
有没有写这更简单的方法?
如果(MyString的==|| myString的== NULL)
{
...
解决方案
是的,有一个辅助方法,正是这一点已经:
如果(string.IsNullOrEmpty(MyString的)){
...
}
I'm sure I've missed something here. With a certain project I need to check if a string is empty or null.
Is there an easier way of writing this?
if(myString == "" || myString == null)
{
...
解决方案
Yes, there's a helper method for exactly this already:
if (string.IsNullOrEmpty(myString)) {
...
}
这篇关于写空或空的更简单的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文