- 谈谈什么是锚文本及锚文本的作用
- indexOf,lastIndexOf和substring 用法详解
- Vue 项目中的 views 和 components 文件夹有什么区别?
- round函数
- DataList用法之小博客
- 如何判断一个网站的权重值
- 网站建设及优化要从四个方面斟酌
- 经典SQL语句大全之基础篇
- DIV+CSS如何控制html标签li的样式,比如删除前面的点
- blockquote标签的用途有哪些?
邮箱:
手机:15383239821
String.IsNullOrEmpty 方法
指示指定的字符串是 null 还是 Empty 字符串。其实就是判断字符串是空引用,或值为空。如刚定义一个字符串就是Empty(空)的。
命名空间: System
程序集: mscorlib(在 mscorlib.dll 中)
result = s == null || s == String.Empty;
语法:
public static bool IsNullOrEmpty(
string value
)
参数
- value
-
类型:System.String
要测试的字符串。
返回值
类型:System.Boolean
示例
稍微修改了下MSDN的例子。
protected void Page_Load(object sender, EventArgs e)
{
string s1 = "abcd";
string s2 = "";
string s3 = null;
string s4 = " ";
Response.Write(string.Format("String s1 {0}.", Test(s1)) + "<br />");
Response.Write(string.Format("String s2 {0}.", Test(s2)) + "<br />");
Response.Write(string.Format("String s3 {0}.", Test(s3)) + "<br />");
Response.Write(string.Format("String s4 {0}.", Test(s4)) + "<br />");
}
public static String Test(string s)
{
if (String.IsNullOrEmpty(s))
{
return "is null or empty";
}
else if(String.IsNullOrEmpty(s.Trim()))
{
return "its Trim is null or empty";
}
else
{
return String.Format("(\"{0}\") is not null or empty", s);
}
}
-
2023-09-22php中双冒号什么意思?
-
2020-08-02微信小程序中“Token校验失败,请检查确认”解决方法
-
2012-06-30地方门户网站如何发展
-
2014-06-13VB中Split函数的用法
-
2023-10-02Jquery中slideDown()用法详解
-
2023-09-18配置和查看composer镜像
