Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student : IEquatable<Student>
- {
- public string Name { get; }
- public decimal Gpa { get; }
- public Student(string Name, decimal Gpa)
- {
- this.Name = Name;
- this.Gpa = Gpa;
- }
- public bool Equals(Student other) // for IEquatable<Student>
- {
- return other != null && Equals(Name, other.Name) && Equals(Gpa, other.Gpa);
- }
- public override bool Equals(object other)
- {
- return this.Equals(other as Student);
- }
- public override int GetHashCode()
- {
- return (Name?.GetHashCode()*17 + Gpa?.GetHashCode()).GetValueOrDefault();
- }
- public Student With(string Name = this.Name, decimal Gpa = this.Gpa) => new Student(Name, Gpa);
- public void Deconstruct(out string Name, out decimal Gpa)
- {
- Name = self.Name;
- Gpa = self.Gpa;
- }
- }
Add Comment
Please, Sign In to add comment