Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-46310: New code suggestion: "Check if has key" (for dictionaries, akin to "Check if is null")

$
0
0
Reporter Igor Abade (t-shooter) Igor Abade (t-shooter)
Created Jul 26, 2007 9:48:13 PM
Updated Apr 13, 2018 3:33:27 PM
Resolved Apr 13, 2018 3:33:24 PM
Subsystem Code Analysis
Assignee Ilya Ryzhenkov (orangy)
Priority Normal
State Fixed
Type Feature
Fix version Unidentified prior version
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions
Much like the "Check if is null" code suggestion, a "Check if has key" suggestion, invoked in an expression invoking the indexer of a dictionary:

Given the following code:
    Dictionary<string,string> dict;
string value = dict["mykey"];
If the user invoked the "Check if has key" code suggestion, then the following code would be generated:
    Dictionary<string,string> dict;

if (dict.ContainsKey("mykey"))
{
string value = dict["mykey"];
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>