Last active
March 31, 2021 13:30
-
-
Save sasan-salem/b931256b949199b4d27e8a603f50cc3c to your computer and use it in GitHub Desktop.
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
class NumberEqualityComparer : IEqualityComparer<Student> | |
{ | |
public bool Equals(Student s1, Student s2) | |
{ | |
if (s1 == null && s2 == null) | |
return true; | |
else if (s1 == null || s2 == null) | |
return false; | |
else if (s1.Number == s2.Number) | |
return true; | |
else | |
return false; | |
} | |
public int GetHashCode(Student student) | |
{ | |
return student.Number.GetHashCode(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment