1
對不起,很難給這個問題一個正確的標題?只有選擇了一個選項時,選擇了一個單選按鈕SelectedItem.Text的簡寫語法?
我基本上是在我的web表單的幾個單選按鈕列表中添加大量文本,以形成我的應用程序中的電子郵件正文。所以,我的代碼如下所示:
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
我不如果你瞭解我的觀點,如果錯誤的話,不需要空白字符串。
這只是我真的有點迂腐與我的代碼。提前致謝。