且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

调用List< T> .Clear()导致IndexOutOfRangeException

更新时间:2022-06-04 08:48:25

典型的情况是,当有多个线程访问同一列表时.

A typical case is when you have multiple threads accessing the same list.

如果一个线程在另一个线程清除列表时删除了一个项目,则可能引发此异常.

If one thread deletes an item while the list is being cleared by another thread, this exception could be thrown.

请记住,不是线程安全的 List< T> 类.

Remember the List<T> class is not thread-safe.