-4

我怎么能写一个说以下(伪代码)的while循环:

While the index of "blahblah" in string 1 exists

do this
4

2 回答 2

3
while(string1.Contains("blahblah")) {
    // do this
}

成功编译为 C# 的伪代码。0 个错误,0 个警告。所用时间:0:00:01.860。

于 2012-05-26T23:01:42.677 回答
0
  var string1 = "blahblah blahblah blahblah blahblah ";
  int pos = -1;
  while (0 >= (pos = string1.IndexOf("blahblah", pos + 1)))
  {
     // do this.
  }
于 2012-05-26T23:06:10.773 回答