抱歉,很难给这个问题一个合适的标题?
我基本上是在我的网络表单中的几个单选按钮列表中将大量文本附加在一起以形成我的应用程序中的电子邮件正文。所以我的代码如下所示:
StringBuilder body = new StringBuilder();
body.Append("<strong>For question1: </strong> " + ((rblQuestion1.SelectedIndex > -1) ? rblQuestion1.SelectedItem.Text : "") + "<br /><br />");
所以我的问题是我是否必须使用以下语法:
((rblQuestion1.SelectedIndex > -1) ? rblQuestion1.SelectedItem.Text : "")
我真正想要的是:
(rblQuestion1.SelectedIndex > -1) ? rblQuestion1.SelectedItem.Text
如果您理解我的观点,我不需要空字符串替代项。
只是我对我的代码有点迂腐。提前致谢。