【发布时间】:2010-09-27 20:26:32
【问题描述】:
我正在实现一个列表,我想知道 IndexOutOfRange 的定义。您认为以下哪一项更好?
/// <exception cref="IndexOutOfRangeException">if index is less than 0
/// or greater than <see cref="Count"/>
public T this[int index] { get { return myArray[index]; } }
或者
/// <exception cref="IndexOutOfRangeException">if index outside the valid range
/// for an array of length equal to <see cref="Count"/></exception>
public T this[int index] { get { return myArray[index]; } }
我正在考虑从 .NET 语言中使用此类的情况,该语言从 1 开始索引数组。我对此主题了解不多,但是第二个版本比第一个更好吗?
【问题讨论】: