private static void CheckRange(Int32 fromIndex, Int32 toIndex) {
if (fromIndex < 0) {
throw new IndexOutOfRangeException("fromIndex cannot be less than zero.");
}
if (toIndex < 0) {
throw new IndexOutOfRangeException("toIndex cannot be less than zero.");
}
if (fromIndex > toIndex) {
throw new IndexOutOfRangeException("fromIndex cannot be greater than toIndex.");
}
}