首页 > Windows开发 > 详细

C#:string判空

时间:2017-06-16 13:14:51      阅读:322      评论:0      收藏:0      [点我收藏+]

1.  string.IsNullOrEmpty (str)    

.Net 2 可用,也就是 Unity 能用

str = “”    ---> true

str = “ ”   ---> false

str = null  ---> true

 

2. String.IsNullOrWhiteSpace(str)  

namespace为:System.String

.Net 4 可用,也就是 Unity 不能用

本质上相当于:string.IsNullOrEmpty(value) || value.Trim().Length == 0;

 

 

str = ""    ---> true

 

str = "   "  ---> true

 

str = null  ---> true

 

C#:string判空

原文:http://www.cnblogs.com/makebetter/p/7026879.html

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