Skip to content

Instantly share code, notes, and snippets.

@sasan-salem
Created March 31, 2021 10:40
Show Gist options
  • Save sasan-salem/ccf826232a0676ee3c1e3ac4389f62da to your computer and use it in GitHub Desktop.
Save sasan-salem/ccf826232a0676ee3c1e3ac4389f62da to your computer and use it in GitHub Desktop.
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