我怎么能写一个说明以下(伪代码)的while循环:
While the index of "blahblah" in string 1 exists
do this
答案 0 :(得分:3)
while(string1.Contains("blahblah")) {
// do this
}
伪代码编译成C#成功。 0错误,0警告。所用时间:0:00:01.860。
答案 1 :(得分:0)
var string1 = "blahblah blahblah blahblah blahblah ";
int pos = -1;
while (0 >= (pos = string1.IndexOf("blahblah", pos + 1)))
{
// do this.
}