1)判断字符串是否为空
string strValue = Request["xxx"];
if(string.IsNullOrEmpty(strValue) || strValue == "undefined")
错误
2)查找字符串
int pos = IndexOf("IMG", System.StringComparison.OrdinalIgnoreCase);
if(pos >= 0)
//找到
3)分割为数组
string[] split = words.Split(new char[] { ',', '.' });//返回:{"1","2","3","","4"}
string[] split = words.Split(new Char[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2","3","4"} 不保留空元素
string[] split = words.Split(new string[] { ",", "." }, 6, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素
4)字符串比较(忽略大小写)
string A = "aBc";
string B = "AbC";
if (string.Compare(A, B, true) == 0)
Response.Write("一致");
else
Response.Write("不一致");
1)判断字符串是否为空
string strValue = Request["xxx"];
if(string.IsNullOrEmpty(strValue) || strValue == "undefined")
错误
2)查找字符串
int pos = IndexOf("IMG", System.StringComparison.OrdinalIgnoreCase);
if(pos >= 0)
//找到
3)分割为数组
string[] split = words.Split(new char[] { ',', '.' });//返回:{"1","2","3","","4"}
string[] split = words.Split(new Char[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2","3","4"} 不保留空元素
string[] split = words.Split(new string[] { ",", "." }, 6, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素
4)字符串比较(忽略大小写)
string A = "aBc";
string B = "AbC";
if (string.Compare(A, B, true) == 0)
Response.Write("一致");
else
Response.Write("不一致");