int starItemCount = _starTextArrary == null 5 :_starTextArrary.Length; 这句定义该怎么解释呀

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 21:31:06
intstarItemCount=_starTextArrary==null5:_starTextArrary.Length;这句定义该怎么解释呀intstarItemCount=_starTextA

int starItemCount = _starTextArrary == null 5 :_starTextArrary.Length; 这句定义该怎么解释呀
int starItemCount = _starTextArrary == null 5 :_starTextArrary.Length; 这句定义该怎么解释呀

int starItemCount = _starTextArrary == null 5 :_starTextArrary.Length; 这句定义该怎么解释呀
等价于下面的语句
int starItemCount;
if(_starTextArray == null)
{
starItemCount = 5;
}
else
{
starItemCount = _starTextArray.Length;
}
(bool)?a:b;三目运算符,bool为真返回a,否则返回b.