首页 > 解决方案 > Console.WriteLine 不工作

问题描述

我正在做一个 Windows 窗体应用程序。我想从控制台获取信息。我找到了这段代码:

using System.Runtime.InteropServices;
using System;

[DllImport("kernel32.dll", SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();

private void Form_Load(object sender, EventArgs e)
{
     Console.WriteLine("Test");
}

控制台正在打开,但我看不到任何输出。我也试过System.Diagnostics.Debug.WriteLine(string message)System.Diagnostics.Trace.WriteLine(string message)。我应该怎么办?

标签: c#console-application

解决方案


推荐阅读