Home > front end >  Shortcut for and/or evaluation
Shortcut for and/or evaluation

Time:02-05

Is there a shortcut for the following evaluation? One where I do not need to specify value a twice?

(a && b || a && c)

Thank you. :)

CodePudding user response:

This should work for you:

(a && (b || c))

CodePudding user response:

If the condition with braces isn't clear enough for you:

switch (a)
{
    case true when b || c:
        Console.WriteLine($"{a} | {b} | {c}");
        break;
    default:
        Console.WriteLine("Nope!");
        break;
}   

https://dotnetfiddle.net/8RCcCr

  •  Tags:  
  • Related