我敢肯定,我错过了一些东西在这里。具有一定的项目,我需要检查,如果字符串为空或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)) {
...
}