Linked Questions
20 questions linked to/from Does .NET have a way to check if List a contains all items in List b?
0 votes
2 answers
5k views
Contains on two values? [duplicate]
I've got a List properties that must contain both pivot1 and pivot2. How can I make Contains work with BOTH values? List<string> properties = line.Split('|').ToList(); string pivot1 = "value1";...
-2 votes
4 answers
258 views
How can I know if ListA has everything ListB has? [duplicate]
If I have the following... List<string> listA = new List<string>(); listA.Add("a"); listA.Add("b"); listA.Add("c"); listA.Add("d"); List<string> listB = new List<string>(); ...
2 votes
3 answers
968 views
String List in Where Condition [duplicate]
Below is my class: public class Test { public string Name {get;set;} public int ID {get;set;} public IList<string> Tags {get;set;} Public Test() { Tags = new List&...
1 vote
1 answer
172 views
Verify that a list has all the other list values [duplicate]
I have 2 int arrays, arr1, and arr2 eg, what is the most efficient way to verify that the arr1 contains All items that arr2 contains. Preferentially returning bool. eg. arr1 = [1,2,3,4] arr2 = [1,2,...
0 votes
3 answers
172 views
C# Is List contained in Another list? [duplicate]
I have this set: List<short> delegatingUserRoles = await (from urols in _dbContext.UsersRoles join u in _dbContext.Users on urols.UserId ...
170 votes
10 answers
68k views
Check whether an array is a subset of another
Any idea on how to check whether that list is a subset of another? Specifically, I have List<double> t1 = new List<double> { 1, 3, 5 }; List<double> t2 = new List<double> { 1,...
3 votes
9 answers
2k views
Check if all elements in List1<T> are in List2<T> C#
Is it possible to Know or check if all elements in List1 is a part of List2 ? Example if I have List1 = { 1,2,3,4 } List2 = { 1,2,3,5,6,4 } I want to get True if all elements in List 1 are in List 2 ...
17 votes
6 answers
6k views
How do I do an integer list intersection while keeping duplicates?
I'm working on a Greatest Common Factor and Least Common Multiple assignment and I have to list the common factors. Intersection() won't work because that removes duplicates. Contains() won't work ...
11 votes
4 answers
8k views
Check if a string contains particular characters in any order
The best way that I can explain what I'm trying to do is by giving an example: I have a string StackOverflow in my database and when a user types OAW I would like to return that string and any other ...
6 votes
4 answers
9k views
Check if one list contains all items from another list in order
How can I determine if List A contains all of the elements from List B in the same order? List A can have additional elements that List B does not have, but must contain all elements of List B in ...
3 votes
1 answer
3k views
Use linq to find DataTable(Name) in a DataSet using unique list of Column Names
I got roped into some old code, that uses loose (untyped) datasets all over the place. I'm trying to write a helper method to find the DataTable.Name using the names of some columns.....(because the ...
-2 votes
2 answers
240 views
How to check if a List<T> contains another List<T> [duplicate]
Is there any elegant way in c# to check whether a List<T> contains a sub-List<T> similar to string.Contains(string)? Let's say e.g. I want to test for example whether List A is contained ...
1 vote
6 answers
256 views
Function that would tell if a list is a ordered subset of another list with the proper order c# or java
I am looking at an algorithm that does the following I have two List<String>, say List<String> A == {"20", "32A", "50K", "50F", "50D", "70", "72"} List<String> B == {"20", "32A", "...
0 votes
3 answers
315 views
Look for equality in selected listbox items
Is it possible to compare two listboxes and their respected selected values? Basically I want to check if listbox A's selected values == listbox B's selected values. I tried this code, but it didn't ...
1 vote
1 answer
374 views
Check if a List "A" contains every element from List "B"
It might sound like this answer was asked before, but it is not the same. I was looking for a way to check if a List "A" contains all the elements from a List "B" and i got the answer from this ...