String.IsNullOrEmpty官方示例
2024-09-05 20:38:41
// 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";}
最新文章
- CoreData的一些简单运用
- java 下载Excel模板
- Linux DNS配置
- Gym 100703K Word order 贪心
- osg,vtk,ogre的区别
- 织梦后台更新,报错DedeCMS Error:Tag disabled:"php" more...
- rsync 实现实时增量备份
- win8系统 Reflect 破解
- uestc 1720无平方因子数
- leetcode面试准备: Maximal Rectangle
- 在jsp中选中checkbox后 将该记录的多个数据获取,然后传到Action类中进行后台处理 双主键情况下 *.hbm.xml中的写法
- 真机调试报错:Could not find Developer Disk Image 或 Could not locate device support files.
- linux性能分析命令top
- 2013第49周一jsp标签
- Kubernets 资源类型简介
- 轻松搞定表白女朋友:Android版APP (零基础也可直接下载软件)
- MySQL面试题中:主从同步部署介绍
- Django-Oscar小记:如何使用高版本Django开发网页的SEO模块
- shell 读取配置文件的方法
- STL中的map、unordered_map、hash_map
热门文章
- C# 异步编程,async与await的简单学习
- [BZOJ2791]:[Poi2012]Rendezvous(塔尖+倍增LCA)
- Floating Point Math
- python之正则匹配match:search findall
- Singleton(Java)
- kubernetes配置dashborad,web界面
- MyRocks安装部署
- ping: sendto: No route to host
- cocos2dx基础篇(15) 列表视图CCTableView
- 初学node.js-nodejs中实现用户注册路由