Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 641 Bytes

RCS1186.md

File metadata and controls

36 lines (25 loc) · 641 Bytes

RCS1186: Use Regex instance instead of static method

Property Value
Id RCS1186
Category Usage
Severity Hidden

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)