Skip to content

Instantly share code, notes, and snippets.

@sasan-salem
Last active March 31, 2021 13:30
Show Gist options
  • Save sasan-salem/09f13439cc1e12e6a07e431a100b9159 to your computer and use it in GitHub Desktop.
Save sasan-salem/09f13439cc1e12e6a07e431a100b9159 to your computer and use it in GitHub Desktop.
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