WebDec 13, 2024 · Using linq, how can I retrieve a list of items where its list of attributes match another list? Take this simple example and pseudo code: List listofGenres = new List () { "action", "comedy" }); var movies = _db.Movies.Where (p => p.Genres.Any () in listofGenres); c# linq Share Follow edited Dec 13, 2024 at 10:41 Luke Girvin WebMar 11, 2016 · You can do so easily using Any instead of Contains: List list = new List (); list.Add ("Horse"); list.Add ("Shorse"); var needle = "horse"; var contains = list.Any (x => x.ToLower () == needle.ToLower ()); // true Share Improve this answer Follow edited Mar 11, 2016 at 23:40 answered Mar 11, 2016 at 23:36 Gediminas Masaitis
How to use Linq to check if a list of strings contains any string in a ...
WebMar 31, 2015 · How to find a string is already present in a list.For example i have a list that contains data now if i want to write the data in to another list during this i want to keep a condition whether the string is already present in the list.I am using the below code but its not working can you kindly help me C# WebYou need this: myList.Where (listStrinEntry => myString.IndexOf (listStringEntry) != -1) Where: myList is List has the values that myString has to contain at any position. So de facto you search if myString contains any of the entries from the list. cheap watch brands reddit
c# - linq where list contains any in list - Stack Overflow
WebC# 使用List.Contains方法查找字符串返回false,但手动比较返回true,c#,.net,string,string-comparison,C#,.net,String,String Comparison,我有一个字符串列表,我试图确定其中一个是否与针字符串匹配。 WebFeb 25, 2015 · public class CustomerListList : List { } public class CustomerList : List { } public class Customer { public int ID { get; set; } public string SomethingWithText { get; set; } } and you can keep it going. to the infinity and beyond ! Share Improve this answer Follow edited Sep 28, 2012 at 1:49 WebTo check if an element is present in the list, use List.Contains() method. The definition of List.Contains() method is given below. bool List.Contains(int item) If given … cheap watch boxes for men