Console.WriteLine不会在输出窗口中显示出来会在、窗口中、Console、WriteLine

2023-09-03 09:08:52 作者:苏陌染。

我已经把一些 Console.WriteLine 调用测试,但他们没有出现在输出框?

I have put some Console.WriteLine calls in to test, but they aren't appearing in the output box?

public static ArrayList myDeliveries = new ArrayList();
    public mainForm()
    {
        InitializeComponent();
    }

   private void mainForm_Load(object sender, EventArgs e)
    {
        if (!File.Exists("../../MealDeliveries.txt"))
        {
            MessageBox.Show("File not found!");
            return;
        }

        using (StreamReader sr = new StreamReader("../../MealDeliveries.txt"))
        {
            //first line is delivery name 
            string strDeliveryName = sr.ReadLine();
            Console.WriteLine("some tetttttttttt23423423423423423ttttttttttttttttttttttt");
            while (strDeliveryName != null)
            {
                //other lines 
                Delivery d = new Delivery(strDeliveryName, sr.ReadLine(),
                                          sr.ReadLine(), sr.ReadLine(),
                                          sr.ReadLine(), sr.ReadLine(),
                                          sr.ReadLine());
                mainForm.myDeliveries.Add(d);

                //check for further values
                strDeliveryName = sr.ReadLine();
            }
        }
        displayDeliveries();


    }


    private void displayDeliveries()
    {
        lstDeliveryDetails.Items.Clear();
        Console.WriteLine("some tettttttttttttttttttttttttttttttttt");
        Console.WriteLine(mainForm.myDeliveries.Count);
        foreach (Delivery d in mainForm.myDeliveries)
        {
            lstDeliveryDetails.Items.Add(d.DeliveryName);

        }
    }

谁能帮助??

Can anyone help??

推荐答案

如果您打算在生产中使用这个输出,然后使用的Debug 类Zach建议。

If this is just some temporary debugging code that you're using to verify that certain code is being executed or has the correct values, then use the Debug class as Zach suggests.

如果你绝对必须使用控制台,那么你就可以attach在程序的方法的控制台。

If you absolutely must use the console, then you can attach a console in the program's Main method.