This is not a specific question but a generic question which was in my mind from long time
I have to check one variable if it contains a value from a list of strings
for e.g.
status == "Open" || status =="Active" || status =="Reopen" || status = "InActive" etc..
In SQL it is very easy to write this kind of statements e.g.
select * from ticket where status in (“Open”,”Active”,”Reopen”,”InActive)
I wonder we don’t have such easy statement in C#?
Do anybody know any easy way like SQL to write this kind of statements without using generic types of if else ,foreach loop or LINQ etc..
I know LINQ is there but still it is not as simple as IN of sql
You can also use the Contain method instead of the Any method, but use the Any method if there’s any comparement logic you would like to implement, instead of the default equality comparer.
OR
Implement extensions to support IN method:
And use like this: