In sql, I can make an if statement like the following If MY_STATE in (1,2,3,4)
In C# I have to type if(MY_STATE == STATE.CT || MY_STATE == STATE.MA || MY_STATE == STATE.VA || MY_STATE == STATE.RI)
This is obviously more clunky. Can I use LINQ to mimic the "in" statement of sql?
I'm looking for something like if(MY_STATE in (STATE.CT, STATE.MA, STATE.VA, STATE.RI))
if (new [] {State.CT, State.MA, State.VA, State.RI}.Contains(myState)) {
// There you go
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With