【发布时间】:2021-06-29 14:50:41
【问题描述】:
我正在尝试根据是否选中复选框来更改标签的文本?知道这里的三元运算符有什么问题吗?如果我使用“if else”,这将有效
private void chkBxCompress_CheckedChanged(object sender, EventArgs e)
{
string encAndCom = "Encrypted and Compressed String";
string encOnly = "Encrypted String";
chkBxCompress.Checked ? outputLabelEnc.Text = encAndCom : outputLabelEnc.Text = encOnly;
}
【问题讨论】:
标签: c# winforms conditional-operator