Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Latest commit

 

History

History
33 lines (25 loc) · 581 Bytes

MD0011.md

File metadata and controls

33 lines (25 loc) · 581 Bytes

MD0010: TryGetValue can be replaced with ContainsKey when discarding value

Property Value
Id MD0011
Category Performance
Severity Warning

Example

Code with Diagnostic

const string arg = "hello";
var dict = new Dictionary<string, string>();

if (dict.TryGetValue(arg, out var _)) // MD0011
{
    // Do something here
}

Code with Fix

const string arg = "hello";
var dict = new Dictionary<string, string>();

if (dict.ContainsKey(arg))
{
    // Do something here
}