Is there a shorthand syntax in C # to do this:
if ((x == 1) || (x==2) || (x==5) || (x==13) || (x==14))
... shorter? Something like (hypothetically)
if (x in {1, 2, 5, 13, 14})
I feel as if it exists, I just mentally approached thoughts and Googly. In fact, I often have to check a bunch of listings, and this is just unreadable. I also hate doing a little helper function if the language already supports it.
Thanks in advance!
Edit
There are smart solutions containing lists ... but I was hoping for some kind of clean logical construction. If this does not exist, so be it. Thank!
source
share