private void EnsureIndexInRange(DateTime dt1, DateTime dt2, out int idx1, out int idx2) { if (dt1 >= dt2) throw new ArgumentException("dateTime1 must be smaller than dateTime2"); idx1 = GetIndex(dt1, IndexOption.Null); idx2 = GetIndex(dt2, IndexOption.Null); if (idx1 == -1) throw new ArgumentOutOfRangeException("dateTime1 is out of range"); if (idx2 == -1) throw new ArgumentOutOfRangeException("dateTime2 is out of range"); } }