string output;
output = "Name:" +this.textBoxName.Text + "\r\n";
output += "Address:" + this.textBoxAddress.Text + "\r\n";
output += "Occupationg:"+(string) (this.checkBoxProgrammer.Checked?"Pragrommer":"Not a Pragrommer") +"\r\n";
output += "Sex:" + (string)(this.radioButtonmale.Checked ? "Feamle" : "Male") +"\r\n";
麻烦看看这几句,为何红色部分用括号将bool等式括起来,语句就能通过。
output = "Name:" +this.textBoxName.Text + "\r\n";
output += "Address:" + this.textBoxAddress.Text + "\r\n";
output += "Occupationg:"+(string) (this.checkBoxProgrammer.Checked?"Pragrommer":"Not a Pragrommer") +"\r\n";
output += "Sex:" + (string)(this.radioButtonmale.Checked ? "Feamle" : "Male") +"\r\n";
麻烦看看这几句,为何红色部分用括号将bool等式括起来,语句就能通过。
这是一个逻辑表达式呀,要不然会分不清楚怎么加的
(string)(this.radioButtonmale.Checked ? "Feamle" : "Male") 带颜色部分是一个选择运算啊,这个远算结束后在拼接字符串,那个“string”强制转换我觉得没有也可以,
+"\r\n";
((string)this.radioButtonmale.Checked) ?
这个当然就不对了
打上括号系统会认为是一个整体
就像你做运算时 打上括号就是为了把他作为一个整体来计算