开发者

Some problems with for-loop

EDIT question to make it understandable.

Today I tried to do a programm analize a html file, but开发者_运维技巧 I had some problems. When I debug my project it crashes, and doesn't respond to my commands. There are my split code:

    string Riga = "<html> <head> </head> <body> </body> </html>";
    int c = 0;

    for(int i = 1; i < 10; i++)
    {
         for (int j = i + 1; Riga[j - 1] != '>'; j++)
         {
              c++;
              //My code
         }
    }

    for (int i = 0; Riga[i] < Riga.Count(); i++)
    {
         //My code
    }

I think that the problem are in the for-loops, but I'm not sure. So can someone explain to me what's wrong? Thank you very much!


It looks like you open the possibility for an infinite loop here:

for (int j = i + 1; Riga[j - 1] != '>'; j++)

EDIT: also, what's about this line?

for (int i = 0; Riga[i] < Riga.Count(); i++)

Why are you comparing the character to the length of the line? Shouldn't it be:

for (int i = 0; i < Riga.Count(); i++)

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜