0

わかりました、皆さんが提案したすべてのことを試しましたが、まだうまくいきません. 理由はわかりませんが、出力がキックされないこともあれば、正しくない出力が出力されることもあります。私は何を間違っていますか。

 InPutBox = Input.Text;
        int x = 1;
        var lines = Input.Text.Split(new string[] { Environment.NewLine },StringSplitOptions.None);

        for (var index = 0; index < lines.Length; index++)
        {

            var line = lines[index];

            do
            {
                x++;
                System.Console.WriteLine("'{0}'", InPutBox);
                bool test1 = InPutBox.StartsWith("11600");
                bool test2 = InPutBox.EndsWith("(");
                if (test1 && test2)
                {
                    int first = InPutBox.IndexOf("11600");
                    int last = InPutBox.LastIndexOf("(");
                    InPutBox = InPutBox.Substring(first, last - first);
                }
            }
            while (x < 50);
            System.Console.WriteLine("'{0}'", line);
            if ((line.StartsWith("11600") && line.EndsWith("(")))
            {
                MessageBox.Show("These are errors in line" + index + ": " + line);
                break;
            }

        }
4

3 に答える 3

0
private void InPutBoxMethod()
    {
        // split text into lines
        var lines = textBox1.Text.Split(new string[] {Environment.NewLine}, StringSplitOptions.None);

        // loop through all lines and check for errors
        for (var index = 0; index < lines.Length; index++)
        {
            var line = lines[index];
            System.Console.WriteLine("'{0}'", line);
            if ((line.StartsWith("W") && line.EndsWith("0")))
            {
                MessageBox.Show("These are errors in line " + index + ": " + line);
                break;
            }
        }
    }
于 2013-07-17T23:09:06.987 に答える