Whats the best way to print out \"Yes\" or \"No\" depending on a value
In my view I want to print out
Model.isStudent
and I dont want True or False,
Write a helper method:
public static class MyExtensions { public static string FormatBool(this HtmlHelper html, bool value) { return html.Encode(value ? "Yes" : "No"); } }
And use it like this:
<%= Html.FormatBool(Model.IsStudent) %>