Skip to content

Instantly share code, notes, and snippets.

@InvaderZim85
Created June 12, 2019 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InvaderZim85/0059290582b426ae613177493c9a4002 to your computer and use it in GitHub Desktop.
Save InvaderZim85/0059290582b426ae613177493c9a4002 to your computer and use it in GitHub Desktop.
Example for the list comparsion
public static Main()
{
var listOne = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var listTwo = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
var resultOne = ListEquals(listOne, listTwo);
var resultTwo = ListEquals(listTwo, listOne);
if (resultOne && resultTwo)
{
Console.WriteLine("Lists equal.");
}
else
{
Console.WriteLine("Lists not equal.");
}
}
private static bool ListEquals(List<int> listOne, List<int> listTwo)
{
foreach (var entry in listOne)
{
if (!listTwo.Any(a => a == entry))
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment