Contains and Remove already throw if the key is null, so there's no
need for additional null checks later in these methods.
return dict.ContainsKey(key);
}
- if (key != null) {
- foreach (TItem item in Items) {
- if (comparer.Equals(GetKeyForItem(item), key)) return true;
- }
+ foreach (TItem item in Items) {
+ if (comparer.Equals(GetKeyForItem(item), key)) return true;
}
return false;
}
return false;
}
- if (key != null) {
- for (int i = 0; i < Items.Count; i++) {
- if (comparer.Equals(GetKeyForItem(Items[i]), key)) {
- RemoveItem(i);
- return true;
- }
+ for (int i = 0; i < Items.Count; i++) {
+ if (comparer.Equals(GetKeyForItem(Items[i]), key)) {
+ RemoveItem(i);
+ return true;
}
}
return false;