Linked Questions
34 questions linked to/from Compare two List<T> objects for equality, ignoring order
193
votes
21
answers
120k
views
Comparing two collections for equality irrespective of the order of items in them
I would like to compare two collections (in C#), but I'm not sure of the best way to implement this efficiently.
I've read the other thread about Enumerable.SequenceEqual, but it's not exactly what I'...
7
votes
1
answer
3k
views
Compare Values of 2 Lists C# [duplicate]
I want to compare the values of two lists for a program I'm making. I want it to compare the 1st value of List 1 to the first value of List 2, and then the second value of List 1 to the second value ...
1
vote
3
answers
7k
views
How can I compare two lists of objects with ingorance of order? [duplicate]
I'm sure that my question is similar to many questions asked on StackOverflow. But I think that my problem is a little bit different from the questions asked here.
What I need exactly is to compare ...
0
votes
3
answers
1k
views
What's the best way to determine whether two List<T> objects contain the same set of values, even if they are not in the same order? [duplicate]
I have two List<T> objects (where T is the same type for both objects), and I need to be able to determine whether they contain the same set of values, even if the values aren't in the same ...
-1
votes
3
answers
93
views
LINQ to see if all items in an object's List property are included in the current selection [duplicate]
I have a Key object that has an attribute of type List<int> and it is called KeyProperties. Key object also has an int Id attribute.
class Key
{
public int Id;
public List<int> ...
1
vote
0
answers
78
views
Comparing two list [duplicate]
I have two string list -
List<string> ObjList1;
List<string> ObjList2;
How can I compare these two list efficiently, such a way that these should have exact match of parameter ...
0
votes
0
answers
71
views
Can anyone suggest a better linq to check if two list have exactly same contents? [duplicate]
I used the following 2 linq queries to check if two list are have exactly same contents(the type of list doesn't matter, assume List of string)
bool haveSameContents = list1.All(x=>list2.Any(y=>...
297
votes
5
answers
421k
views
Check if two lists are equal
I have a class as follows:
public class Tag {
public Int32 Id { get; set; }
public String Name { get; set; }
}
And I have two lists of tag:
List<Tag> tags1;
List<Tag> tags2;
I ...
3
votes
7
answers
1k
views
How to remove reverse duplicates in a C# Tuple list
Say I have a Tuple List like this:
List<Tuple<string, string>> conflicts = new List<Tuple<string, string>>();
conflicts.Add(new Tuple<string, string>("Maths", "...
1
vote
1
answer
6k
views
Check whether two comma separated strings are equal (for Content set)
I have four string as listed below. Though they have different order of characters and different spacing after comma – they are considered to have same business value.
How do I check that all the ...
2
votes
1
answer
6k
views
C# Compare Lists with custom object but ignore order
I'm trying to compare 2 Lists (wrapped in an object) containing custom objects.
I don't care about the order, but if list 1 contains "1,2,3,4" then list 2 must and only contain those elements. E.g.: "...
1
vote
1
answer
874
views
How to compare two lists in C#?
I have two lists to compare:
I want to compare List A and List B such that if any of the dates from ListB is present in List A then return true.
For example, if 14-01-2020 (which is in List B) is ...
4
votes
2
answers
440
views
C# : using lambda to GroupBy every collection elements
I have a collection of Component and these collections have a collection of Pax:
public class Component
{
public IEnumerable<Pax> Paxes { get; set; }
}
public class Pax
{
public int ...
2
votes
3
answers
430
views
Tuple or other multikey variant for Dictionary, but with permutability
I am scratching my head over the following problem.
I want to create a dictionary, which uses multiple keys. I came along the solutions suggesting tuples as the method of choice. I think this i a good ...
-21
votes
1
answer
2k
views
How do I compare two lists of objects in C#?
public class ClassA
{
public enum1 Type { get;set;}
public List<ClassB> lst1 {get; set;}
}
public class ClassB
{
public string var1 { get;set;}
public int var2 { get;set;}
...