求答案,判断字符串不为空
net吧
全部回复
仅看楼主
level 1
兽不拉基 楼主
判断字符串不为空的时候我用
if (user.DeptID.Length != 0)
{
.......
}
报错

if (user.DeptID != "")
{
..................
}
当user.DeptID为空的时候也进去走里面的代码了,

if (!user.DeptID.Equals(""))
{
.....................
}
也是报错是怎么回事啊?
有没有同学知道我要判断字符串不为空的代码怎么写啊?
2015年07月26日 09点07分 1
level 10
后者……,前者必须初始化
2015年07月26日 12点07分 2
谢谢,我已经解决了[呵呵]
2015年07月26日 13点07分
level 1
isnull
2015年07月30日 06点07分 3
level 8
if(!isNullOrEmpty(user.DeptID)){}
2015年08月12日 06点08分 4
首先你得确定user.DeptID是不是一个字符串,如果压根都取不到值,怎么去判断是不是空么
2015年08月12日 06点08分
1