C#的String类的IsNullOrEmpty方法
来源:互联网 发布:绿色建筑评价软件 编辑:程序博客网 时间:2024/04/27 15:07
// 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.
*/
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.
*/
- C#的String类的IsNullOrEmpty方法
- String.IsNullorEmpty()方法的使用
- String.IsNullOrEmpty()方法的使用
- string.IsNullOrEmpty和string.IsNullOrWhiteSpace方法的区别
- string.IsNullOrEmpty和string.IsNullOrWhiteSpace方法的区别
- string.IsNullOrEmpty和string.IsNullOrWhiteSpace方法的区别
- string.IsNullOrEmpty和string.IsNullOrWhiteSpace方法的区别
- string.IsNullOrEmpty和string.IsNullOrWhiteSpace方法的区别
- string.IsNullOrEmpty和string.IsNullOrWhiteSpace的区别
- String.IsNullOrEmpty 方法
- String.IsNullOrEmpty 方法
- String.IsNullOrEmpty 方法
- String.IsNullOrEmpty方法
- string.IsNullOrEmpty
- NET Framework 类库 String.IsNullOrEmpty 方法
- IsNullOrEmpty()方法
- C# String.Empty, ==,String.IsNullOrEmpty(str)
- C#中String类的几个方法
- 社会万象]从全球夜间卫星地图看世界和国内各地发达程度(转载)
- 旋转卡壳——凸多边形间最大距离
- 股票
- 关于 JavaScript 和 Flash 间的通信
- 一天一个C Run-Time Library 函数(1) __isascii & __iswascii & __toascii
- C#的String类的IsNullOrEmpty方法
- 【站长经验】实力站长的推站经验
- 单链表逆置
- 2008-10-29 我的第一篇文章
- 在Html中,图像使用map标签 [转]
- Cg编程入门 - 我的技术空间 - 博客园
- 免费QQ空间播放器代码
- MYSQL 的 MASTER到MASTER的主主循环同步
- 我到底做错什么了。。。1029