Skip to content

Misleading example in AV1553 #66

@bkoelman

Description

@bkoelman

AV1551 mentions three overloads. The next rule (AV1553) combines them into a single method using optional parameters. But that changes behavior, because it defaults parameter count to 0. Consider changing to:

public virtual int IndexOf(string phrase, int startIndex = 0, int count = -1)
{
    var length = count == -1 ? someText.Length - startIndex : count;
    return someText.IndexOf(phrase, startIndex, length);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions