C# third index of a character in a string

前端 未结 10 1963
甜味超标
甜味超标 2020-12-06 17:18

is there a command that can get the third index of a character in a string? For example:

error: file.ext: line 10: invalid command [test:)]

10条回答
  •  心在旅途
    2020-12-06 17:56

    Please see this answer on a similar question: https://stackoverflow.com/a/46460083/7673306
    It provides a method for you to find the index of nth occurrence of a specific character within a designated string.

    In your specific case it would be implemented like so:

    int index = IndexOfNthCharacter("error: file.ext: line 10: invalid command [test:)]", 3, ':');
    

提交回复
热议问题