Created
March 31, 2021 10:40
-
-
Save sasan-salem/ccf826232a0676ee3c1e3ac4389f62da 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 Student : IEquatable<Student> | |
{ | |
public string Name { get; set; } | |
public int Number { get; set; } | |
public int SerialNo { get; set; } | |
public int Grade { get; set; } | |
public bool Equals(Student other) | |
{ | |
if (other.SerialNo == SerialNo) | |
return true; | |
else | |
return false; | |
} | |
public override bool Equals(object obj) | |
{ | |
if (obj is Student student) | |
return Equals(student); | |
else | |
return false; | |
} | |
public override int GetHashCode() | |
{ | |
return SerialNo.GetHashCode(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment