Last active
March 31, 2021 13:30
-
-
Save sasan-salem/09f13439cc1e12e6a07e431a100b9159 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 SerialNoEqualityComparer : 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.SerialNo == s2.SerialNo) | |
return true; | |
else | |
return false; | |
} | |
public int GetHashCode(Student student) | |
{ | |
return student.SerialNo.GetHashCode(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment