Отражатель говорит мне, что SortedList использует класс ThrowHelper для исключения исключений, вместо того, чтобы бросать их напрямую, например:
public TValue this[TKey key]
{
get
{
int index = this.IndexOfKey(key);
if (index >= 0)
return this.values[index];
ThrowHelper.ThrowKeyNotFoundException();
return default(TValue);
}
где ThrowKeyNotFoundException делает не что иное, как просто:
throw new KeyNotFoundException();
Обратите внимание, что для этого требуется утверждение duff "return default (TValue)", которое недостижимо. Я должен сделать вывод, что это шаблон с преимуществами, достаточно большими, чтобы оправдать это.
Каковы эти преимущества?