SQL Like search in LIST and LINQ in C# -



SQL Like search in LIST and LINQ in C# -

i have list contains list of words needs excluded.

my approach have list contains these words , utilize linq search.

list<string> lstexcludelibs = new list<string>() { "config", "boardsupportpackage", "commoninterface", ".h", }; string strsearch = "boardsupportpackagesamsung"; bool has = lstexcludelibs.any(cus => lstexcludelibs.contains(strsearch.toupper()));

i want find out part of string strsearch nowadays in lstexcludedlibs.

it turns out .any looks exact match. there possibilities of using or wildcard search

is possible in linq?

i have achieved using foreach , contains wanted utilize linq create simpler.

edit: tried list.contains doesn't seem work

you've got wrong way round, should be:-

list<string> lstexcludelibs = new list<string>() { "config", "boardsupportpackage", "commoninterface", ".h", }; string strsearch = "boardsupportpackagesamsung"; bool has = lstexcludelibs.any(cus => strsearch.toupper().contains(cus));

btw - observation but, imho, variable name prefixes 'lst' , 'str' should ommitted. mis-interpretation of hungarian notation , redundant.

c# linq

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -