// This example demonstrates the String.IsNullOrEmpty() method
using System; class Sample
{
public static void Main()
{
string s1 = "abcd";
string s2 = "";
string s3 = null; Console.WriteLine("String s1 {0}.", Test(s1));
Console.WriteLine("String s2 {0}.", Test(s2));
Console.WriteLine("String s3 {0}.", Test(s3));
} public static String Test(string s)
{
if (String.IsNullOrEmpty(s) == true)
return "is null or empty";
else
return String.Format("(\"{0}\") is not null or empty", s);
}
}
/*
This example produces the following results: String s1 ("abcd") is not null or empty.
String s2 is null or empty.
String s3 is null or empty. */

String类提供的这个IsNullOrEmpty方法十分的优雅,英语就是graceful。String的话一般都会有""和null两种情况,如果自己写,用if(s=="" || s==Null)就不太美妙了。

Normal
0

7.8 磅
0
2

false
false
false

EN-US
ZH-CN
X-NONE

st1\:*{behavior:url(#ieooui) }

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}

最新文章

  1. CoreData的一些简单运用
  2. java 下载Excel模板
  3. Linux DNS配置
  4. Gym 100703K Word order 贪心
  5. osg,vtk,ogre的区别
  6. 织梦后台更新,报错DedeCMS Error:Tag disabled:"php" more...
  7. rsync 实现实时增量备份
  8. win8系统 Reflect 破解
  9. uestc 1720无平方因子数
  10. leetcode面试准备: Maximal Rectangle
  11. 在jsp中选中checkbox后 将该记录的多个数据获取,然后传到Action类中进行后台处理 双主键情况下 *.hbm.xml中的写法
  12. 真机调试报错:Could not find Developer Disk Image 或 Could not locate device support files.
  13. linux性能分析命令top
  14. 2013第49周一jsp标签
  15. Kubernets 资源类型简介
  16. 轻松搞定表白女朋友:Android版APP (零基础也可直接下载软件)
  17. MySQL面试题中:主从同步部署介绍
  18. Django-Oscar小记:如何使用高版本Django开发网页的SEO模块
  19. shell 读取配置文件的方法
  20. STL中的map、unordered_map、hash_map

热门文章

  1. C# 异步编程,async与await的简单学习
  2. [BZOJ2791]:[Poi2012]Rendezvous(塔尖+倍增LCA)
  3. Floating Point Math
  4. python之正则匹配match:search findall
  5. Singleton(Java)
  6. kubernetes配置dashborad,web界面
  7. MyRocks安装部署
  8. ping: sendto: No route to host
  9. cocos2dx基础篇(15) 列表视图CCTableView
  10. 初学node.js-nodejs中实现用户注册路由