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, I want Yes or No.... do I Have to write if else statement?
C is not just what students use to learn programming. It's not an academic language. And I would say it's not the easiest language, because C is a rather low level programming language. Today, C is widely used in embedded devices, and it powers most of the Internet servers, which are built using Linux.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
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) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With