In SQL, you can use the following syntax:
SELECT *
FROM MY_TABLE
WHERE VALUE_1 IN (1, 2, 3)
Is there an equivalent in C#? The IDE seems to recognise "in" as a keyword, but I don't seem to be able to find any information on it.
So, is it possible to do something like the following:
int myValue = 1;
if (myValue in (1, 2, 3))
// Do something
Instead of
int myValue = 1;
if (myValue == 1 || myValue == 2 || myValue == 3)
// Do something
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…