ASP.Net checkbox to return a “Yes” or “No” value (instead of True / False)
问题 I am using C# and ASP.Net 3.5, and trying to get a "Yes" / "No" value from checkbox, rather than a True / False. Is there an easy way or do I need to do "if" statements? 回答1: sure try this: string doesThisWork = chkBox.Checked ? "Yes":"No" more info... 回答2: How about adding a extension method to the CheckBox class for this: public static class CheckBoxExtensions { public static string IsChecked(this CheckBox checkBox) { return checkBox.Checked ? "Yes" : "No"; } } Usage: var checkBox = new