Permalink
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (28 sloc) 870 Bytes

RCS1186: Use Regex instance instead of static method

Property Value
Id RCS1186
Category Usage
Default Severity Hidden
Enabled by Default
Supports Fade-Out -
Supports Fade-Out Analyzer -

Example

Code with Diagnostic

private void Bar()
{
    bool isMatch = Regex.IsMatch("abc", @"\w"); // RCS1186
}

Code with Fix

private readonly Regex _regex = new Regex(@"\w");

private void Bar()
{
    bool isMatch = _regex.IsMatch("abc");
}

See Also

(Generated with DotMarkdown)