Console.WriteLine不会在输出窗口中显示出来 [英] Console.WriteLine does not show up in Output window

查看:259
本文介绍了Console.WriteLine不会在输出窗口中显示出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把一些 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??

推荐答案

如果您打算在生产中使用这个输出,然后使用的Trace 类成员。这使得code便携,您可以连接了不同类型的听众,并输出到控制台窗口,调试窗口,日志文件,或者你喜欢的任何其他。

If you intend to use this output in production, then use the Trace class members. This makes the code portable, you can wire up different types of listeners and output to the console window, debug window, log file, or whatever else you like.

如果这是您使用来验证正在执行某些code或具有正确的价值观只是一些临时调试code,然后使用的Debug 类<一href="http://stackoverflow.com/questions/2669463/console-writeline-does-not-show-up-in-output-window/2669496#2669496">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.

如果你绝对必须使用控制台,那么你就可以<一href="http://www.$c$cproject.com/tips/68979/Attaching-a-Console-to-a-WinForms-application.aspx">attach在程序的方法的控制台。

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

这篇关于Console.WriteLine不会在输出窗口中显示出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆