Dictionary looked up twice (CA1854)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key dotnet.performance.double-dictionary-lookup · Severity info · Category performance
Microsoft analyzer CA1854. Flags ContainsKey followed by the indexer on the same key - two lookups where TryGetValue does one.
Incorrect
Section titled “Incorrect”if (cache.ContainsKey(key)) return cache[key];Correct
Section titled “Correct”if (cache.TryGetValue(key, out var value)) return value;