private void ReplaceLast(Object obj) { // deliberately throw the IndexOutOfBoundsException if we screw up. arrayList[arrayList.Count - 1] = obj; } }