首页 > Windows开发 > 详细

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

时间:2018-04-17 10:41:39      阅读:554      评论:0      收藏:0      [点我收藏+]
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或者\"\"");
           }

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!