1

以下のコードで問題が発生しています...実行してもコードが終了しません。これを約1時間デバッグしようとしましたが、何が問題なのか完全に途方に暮れています。OutputDebug(); 基本的に Console.WriteLine(); に似ています。

//Iterate through all lines to find sections
            using (StringReader lineReader = new StringReader(Program))
            {
                int i = 0;
                string line = string.Empty;
                while (line != null)
                {
                    line = lineReader.ReadLine();
                    if (line != string.Empty)
                    {
                        //If the program is exiting (doExit == true), then break the lööp bröther
                    if (doExit)
                            break;

                        //Iterate through all characters in the line
                        foreach (char Character in line)
                    {
                        i++;
                        OutputDebug(i.ToString());
                        if (isOnSameLineAsSectionStart)
                        {
                            sectionName += Character;
                        }
                        else if (Character == ':' && sectionName == string.Empty)
                        {
                            isOnSameLineAsSectionStart = true;
                        }
                        else if (Character == ':' && !isOnSameLineAsSectionStart && sectionName != string.Empty)
                        {
                            OutputDebug("End of section \"" + sectionName + "\" found");
                            OutputDebug(linesInSection.Count() + " lines found total in " + sectionName + "\" during section search");
                            try
                            {
                                sections.Add(sectionName, linesInSection);
                            }
                            catch (Exception)
                            {
                                OutputError("Two/Multiple sections with the same names exist. Ignoring the latest section with the same name");
                            }
                            linesInSection = new List<string>();
                            sectionName = string.Empty;
                            isOnSameLineAsSectionStart = true;
                        }
                    }
                    if (!isOnSameLineAsSectionStart && sectionName != string.Empty)
                    {
                        linesInSection.Add(line);
                    }
                    if (isOnSameLineAsSectionStart && sectionName != string.Empty)
                    {
                        OutputDebug("Start of section \"" + sectionName + "\" found");
                    }
                    if (isOnSameLineAsSectionStart == true)
                    {
                        isOnSameLineAsSectionStart = false;
                    }
                }
                lineReader.Close();
                OutputDebug("In StringReader!" + i);
            }

前もって感謝します!

4

3 に答える 3