Shorthand OR statment #4042
-
Feature Idea: Shorthand if - or statement. Instead of you could instead say I see many people asking this question on Stack Overflow, and even had this discussion with coworkers.. It's not a big deal when variables and values are as short as my example, but consider: I often find myself REALLY wishing there were a quick shorthand method that doesn't involve declaring a new list or array: Forgive me if this has been mentioned before, I'm sure it has but couldn't find any mention of it. This seems like a simple situation most developers beginner to expert would commonly find themselves in. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
With disjunctive patterns in pattern matching in C# 9.0 you can do this: if (x is 1 or 2 or 3) { ... } Although you are limited to constants as the operands. |
Beta Was this translation helpful? Give feedback.
-
Duplicate of #420 |
Beta Was this translation helpful? Give feedback.
-
And if you need non-constants, there is the option for an extension method
which works wonders.
…On Tue, 20 Oct 2020 at 19:05, luckyexpert ***@***.***> wrote:
wow this is pretty slick, this may work for me most of the time when I am
working with constants..
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4042 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADIEDQMFMGWIGBSUIGJNXPLSLXGNHANCNFSM4SYSKNJA>
.
|
Beta Was this translation helpful? Give feedback.
With disjunctive patterns in pattern matching in C# 9.0 you can do this:
Although you are limited to constants as the operands.