return返回两个三元表达式的和,返回不正确,同样要注意在JavaScript中,也是如此

        public string b() {
            string b = "";
            string c = "1313131";
            return b == "" ? "0" : b + c != "" ? c : "0";//结果是0
        
        }

        public int  c()
        {
public string b() {
            string b = "";
            string c = "1313131";
            return (b == "" ? "0" : b) + (c != "" ? c : "0");//
        
        }

        public int  c()
        {
            return (3 == 4 ? 3 : 4 )+ (3 != 4 ? 3 : 4);//

        }



        }

这个需要考虑的是优先级的问题,正确的写法是,在每个三元表达外面写上一个小括号,这样结果才正确

原文地址:https://www.cnblogs.com/hongmaju/p/7508507.html