C# 判断字符串为空(长度为0),或者是null(没有new)

时间:2018-04-17 10:41:39   收藏:0   阅读:555
string str = null;
           if (string.IsNullOrWhiteSpace(str))
           {
               MessageBox.Show("字符串为null");
           }
           if (str.Length == 0)
           {
               MessageBox.Show("字符串为空");
           }
           if (str == "")
           {
               MessageBox.Show("字符串为空");
           }
           if (string.Empty==str)
           {
               MessageBox.Show("字符串为空");
           }
           if (string.IsNullOrEmpty(str))
           {
               MessageBox.Show("判读字符串为null或者\"\"");
           }

 

原文:https://www.cnblogs.com/Peng18233754457/p/8861970.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!