public int CompareTo(object obj) { if (obj is Subject other) { return(LessonName.CompareTo(other.LessonName) ^ Teacher.CompareTo(other.Teacher)); } else { throw new Exception("Несравнимые объекты"); } }
public new int CompareTo(object obj) { switch (obj) { case Lesson other: return(LessonName.CompareTo(other.LessonName) + Teacher.CompareTo(other.Teacher) + StartLesson.CompareTo(other.StartLesson) + FinishLesson.CompareTo(other.FinishLesson) + NameGroup.CompareTo(other.NameGroup) + NumberGroup.CompareTo(other.NumberGroup)); default: throw new Exception("Несравнимые объекты"); } }
public override int GetHashCode() { return(LessonName != null?LessonName.GetHashCode() : 0); }