Created
June 12, 2019 20:17
-
-
Save InvaderZim85/0059290582b426ae613177493c9a4002 to your computer and use it in GitHub Desktop.
Example for the list comparsion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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