Is there an or operator in C#?
I want to do:
if (ActionsLogWriter.Close or ErrorDumpWriter.Close == true)
{
// Do stuff here
}
But I’m not sure how I could do something like that.
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.
C# supports two boolean
oroperators: the single bar|and the double-bar||.The difference is that
|always checks both the left and right conditions, while||only checks the right-side condition if it’s necessary (if the left side evaluates to false).This is significant when the condition on the right-side involves processing or results in side effects. (For example, if your
ErrorDumpWriter.Closemethod took a while to complete or changed something’s state.)