Let's say I have following code:
List<string> numbers = new List<string> { "1", "2" };
List<string> numbers2 = new List<string> { "1", "2"};
if (numbers.Equals(numbers2))
{
}
Like you can see I have two lists with identical items. Is there a way to check if these two lists are equal by using one method?
SOLUTION:
Use SequenceEqual()
Thanks
numbers: { 1, 1, 2}andnumbers2: { 1, 2 }would you consider those equal?SequenceEqual()return truewill do the job. It's also the fastest solution