I am tempted to use an if ... else ... but I am wondering if there’s an easier way? I need to display the true or false result in a message box.
I am tempted to use an if … else … but I am wondering
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
bool.ToStringmethod already does what you want.However in practice it is not that often that you need to explicitly call
ToStringdirectly from your code. If you are already writing a string then the easiest way is to use concatenation:This compiles to a call to
string.Concatand this calls theToStringmethod for you.In some situations it can be useful to use
String.Format, and again theToStringmethod is called for you: