Zum Inhalt springen

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.

if (cache.ContainsKey(key))
return cache[key];
if (cache.TryGetValue(key, out var value))
return value;