A call to ContainsKey(key) followed by an access var set = this[key] results in a double lookup in the dictionary.
Resolution: Replace ContainsKey with TryGetValue.
The code can also be simplified by using collection initializers.
See also: CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method.
A call to
ContainsKey(key)followed by an accessvar set = this[key]results in a double lookup in the dictionary.Resolution: Replace
ContainsKeywithTryGetValue.The code can also be simplified by using collection initializers.
See also: CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method.