从列表反编译来源:
public int RemoveAll(Predicate<T> match)
{
if (match == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
int index1 = 0;
while (index1 < this._size && !match(this._items[index1]))
++index1;
if (index1 >= this._size)
return 0;
int index2 = index1 + 1;
while (index2 < this._size)
{
while (index2 < this._size && match(this._items[index2]))
++index2;
if (index2 < this._size)
this._items[index1++] = this._items[index2++];
}
Array.Clear((Array) this._items, index1, this._size - index1);
int num = this._size - index1;
this._size = index1;
++this._version;
return num;
}
正如你所看到的唯一的时候此方法抛出ArgumentNullException
时的说法实际上是等于null
。
*的list.RemoveAll应该抛出ArgumentNullException如果我把它称为其计列表上零* - 它在哪里说,在[文档](http://msdn.microsoft.com/en-us/library/wdka673a.aspx)? –
如果你写了'_dataNotWrittenToDb.RemoveAll(null)',它会给你'ArgumentNullException'。也许这就是你误解的内容。 –
@JeppeStigNielsen我现在明白了,谢谢 –