C# analog for sql in operator -


there in operator in sql

select * mytable id in (1, 2, 3, 4, 5) 

is there similar sintax in c#, mean

if(variable in (1, 2, 3, 4, 5)){ } 

there isn't 1 can write extension method:

public static class extensions {   public static bool in<t>(this t value, params t[] items)   {       return items.contains(value);   } }  if (v.in(1,2,3,5)) { /* stuff */ } 

i haven't tested it, should good.

update: suggested op, i've corrected few typos.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -