object IDictionary.this[object key] { get { if (IsCompatibleKey(key)) { int i = FindEntry((TKey)key); if (i >= 0) { return(entries[i].value); } } return(null); } set { if (key == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key); } ThrowHelper.IfNullAndNullsAreIllegalThenThrow <TValue>(value, ExceptionArgument.value); try { TKey tempKey = (TKey)key; try { this[tempKey] = (TValue)value; } catch (InvalidCastException) { ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(TValue)); } } catch (InvalidCastException) { ThrowHelper.ThrowWrongKeyTypeArgumentException(key, typeof(TKey)); } } }
void IDictionary.Add(object key, object value) { if (key == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key); } ThrowHelper.IfNullAndNullsAreIllegalThenThrow <TValue>(value, ExceptionArgument.value); try { TKey tempKey = (TKey)key; try { Add(tempKey, (TValue)value); } catch (InvalidCastException) { ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(TValue)); } } catch (InvalidCastException) { ThrowHelper.ThrowWrongKeyTypeArgumentException(key, typeof(TKey)); } }
void System.Collections.IList.Insert(int index, Object item) { ThrowHelper.IfNullAndNullsAreIllegalThenThrow <T>(item, ExceptionArgument.item); try { Insert(index, (T)item); } catch (InvalidCastException) { ThrowHelper.ThrowWrongValueTypeArgumentException(item, typeof(T)); } }
void IList.Insert(int index, object item) { ThrowHelper.IfNullAndNullsAreIllegalThenThrow <T>(item, ExceptionArgument.item); try { this.Insert(index, (T)item); } catch (InvalidCastException ex) { ThrowHelper.ThrowWrongValueTypeArgumentException <object>(item, typeof(T)); } }
int System.Collections.IList.Add(Object item) { ThrowHelper.IfNullAndNullsAreIllegalThenThrow <T>(item, ExceptionArgument.item); try { Add((T)item); } catch (InvalidCastException) { ThrowHelper.ThrowWrongValueTypeArgumentException(item, typeof(T)); } return(Count - 1); }
int IList.Add(object item) { ThrowHelper.IfNullAndNullsAreIllegalThenThrow <T>(item, ExceptionArgument.item); try { this.Add((T)item); } catch (InvalidCastException ex) { ThrowHelper.ThrowWrongValueTypeArgumentException(item, typeof(T)); } return(this.Count - 1); }
Object System.Collections.IList.this[int index] { get { return(this[index]); } set { ThrowHelper.IfNullAndNullsAreIllegalThenThrow <T>(value, ExceptionArgument.value); try { this[index] = (T)value; } catch (InvalidCastException) { ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(T)); } } }
int IList.Add(object?item) // TODO-NULLABLE-GENERIC: nullable if default(T) can be null { ThrowHelper.IfNullAndNullsAreIllegalThenThrow <T>(item, ExceptionArgument.item); try { Add((T)item !); } catch (InvalidCastException) { ThrowHelper.ThrowWrongValueTypeArgumentException(item, typeof(T)); } return(Count - 1); }
public virtual Object this[Object key] { get { if (IsCompatibleKey(key)) { int i = IndexOfKey((TKey)key); if (i >= 0) { return(values[i]); } } return(null); } set { if (!IsCompatibleKey(key)) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key); } ThrowHelper.IfNullAndNullsAreIllegalThenThrow <TValue>(value, ExceptionArgument.value); try { TKey tempKey = (TKey)key; try { this[tempKey] = (TValue)value; } catch (InvalidCastException) { ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(TValue)); } } catch (InvalidCastException) { ThrowHelper.ThrowWrongKeyTypeArgumentException(key, typeof(TKey)); } } }
object?IList.this[int index] // TODO-NULLABLE-GENERIC: nullability is the same as of T { get { return(this[index]); } set { ThrowHelper.IfNullAndNullsAreIllegalThenThrow <T>(value, ExceptionArgument.value); try { this[index] = (T)value !; } catch (InvalidCastException) { ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(T)); } } }