索引超出范围异常和索引超出数组边界异常有什么区别?
“索引超出范围异常”和“索引超出数组异常范围”之间有什么区别吗?
Is there any difference between "Index was out of range exception" and "Index was outside the bounds of the array exception"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它们完全相同。
IndexOutOfRangeException
是抛出的异常类的名称。 Visual Studio 给出的描述为“索引超出了数组范围”。当尝试访问索引超出数组范围的数组元素时,会引发此异常。
请注意,
IndexOutOfBoundsException
类根本不是 C# 的一部分,而是 Java 语言(或 Microsoft 的实现 J#)的一部分。They're exactly the same thing.
IndexOutOfRangeException
is the name of the exception class that is thrown. Its description is given by Visual Studio as "Index was outside the bounds of the array."This exception is thrown when an attempt is made to access an element of an array with an index that is outside of the bounds of the array.
Note that the
IndexOutOfBoundsException
class is not part of C# at all, but rather the Java language (or Microsoft's implementation, J#).