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.
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.
As of C# 9, there is an or keyword that can be used in matching a "disjunctive pattern". This is part of several new pattern matching enhancements in this version.
An example from the docs:
public static bool IsLetter(this char c) => c is >= 'a' and <= 'z' or >= 'A' and <= 'Z';