C# third index of a character in a string

前端 未结 10 1948
甜味超标
甜味超标 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:53

    int pos = -1;
    for ( int k = 0; k < 3; ++k )
    {
      pos = s.indexOf( ':', pos+1 );
      // Check if pos < 0...
    }
    

提交回复
热议问题