DataSet ds = null;
if(ds != null && ds.Tables != null) //1
{
string s="1";
}
if(ds == null && ds.Tables != null) //2
{
string s="1";
}
if(ds != null || ds.Tables != null) //3
{
string s="1";
}
if(ds == null || ds.Tables != null) //4
{
string s="1";
}
--------------------------------
上面那段程序四个判断中,1和4不会抛异常,2,3会抛异常
if(ds != null && ds.Tables != null) //1
{
string s="1";
}
if(ds == null && ds.Tables != null) //2
{
string s="1";
}
if(ds != null || ds.Tables != null) //3
{
string s="1";
}
if(ds == null || ds.Tables != null) //4
{
string s="1";
}
--------------------------------
上面那段程序四个判断中,1和4不会抛异常,2,3会抛异常