Skip to main content

Call string.IndexOf instead of string.Contains

PropertyValue
IdRR0144
Applicable Syntaxmethod invocation
Syntax Spanmethod name
Enabled by Default

Usage

Example #1

before.cs
if (s.Contains("a"))
{
{
after.cs
if (s.IndexOf("a", StringComparison.OrdinalIgnoreCase) != -1)
{
{

Configuration

roslynator_refactoring.call_indexof_instead_of_contains.enabled = true|false