How do I show a console output/window in a forms application?

前端 未结 11 1659
我寻月下人不归
我寻月下人不归 2020-11-22 11:15

To get stuck in straight away, a very basic example:

using System;
using System.Windows.Forms;

class test
{ 
    static void Main()
    { 
        Console.W         


        
11条回答
  •  面向向阳花
    2020-11-22 12:05

    this one should work.

    using System.Runtime.InteropServices;
    
    private void Form1_Load(object sender, EventArgs e)
    {
        AllocConsole();
    }
    
    [DllImport("kernel32.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool AllocConsole();
    

提交回复
热议问题