jeudi 30 avril 2015

why my if statement does not work

Even if the requirement of if statement is true, the Console.WriteLine does not print anything. How should I change here? I need that the program prints next string after div class="trans" lang="ru" and stops before it encounters /div>

string line =string.Empty;

        using(StreamReader sr = new StreamReader("d:/test.txt"))
            try
            {
                while (true)
                {
                    line = sr.ReadLine();


                    if (line == null)
                    {
                        break;
                    }

                    if (line.StartsWith("<div class=\"trans\" lang=\"ru\">"))
                    {
                        Console.WriteLine(line);
                        if (line.StartsWith("</div>"))
                        {
                            break;
                        }
                    }

                }

            }

Aucun commentaire:

Enregistrer un commentaire