public int CompareTo(object obj) { if (obj is Item objectToCompare) { int creationDateComparison = CreationDate.CompareTo(objectToCompare.CreationDate); if (creationDateComparison == 0) { return(Id.CompareTo(objectToCompare.Id)); } else { return(creationDateComparison); } } else { throw new ArgumentException($"An {nameof(Item)} cannot be compared with a {obj?.GetType().FullName ?? null}."); } }