Wednesday, April 25, 2012

Is there any compare operator in c# like SQL's IN statement

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 etc..





No comments:

Post a Comment