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
For your updated question, you could also use a switch-statement.
switch (myvalue)
{
case 1:
case 2:
case 3:
// your code goes here
break;
}
The in
keyword in C# is for the foreach
statement and for LINQ query expressions. There is no functionality equivalent to SQL's in
operator in C# per se, but LINQ offers similar functionality with Contains()
.
var list = {1, 2, 3}
var filtered = (
from item in items
where list.Contains(item)
select item).ToArray().