Is there a C# IN operator?

后端 未结 14 1842
说谎
说谎 2020-12-08 03:51

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

14条回答
  •  执笔经年
    2020-12-08 04:24

    You can do this:

    var x = 99; // searched value
    
    if (new[] {1,2,3,99}.Contains(x))
    {
       // do something
    }
    

提交回复
热议问题