All you need to do is call the windows API function AllocConsloe then use the normal console class here is the form code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace waTest
{
public partial class Form1 : Form
{
[DllImport("Kernel32.dll")]
static extern Boolean AllocConsole( );
public Form1( )
{
InitializeComponent();
}
private void Form1_Load( object sender, EventArgs e )
{
if ( !AllocConsole() )
MessageBox.Show("Failed");
Console.WriteLine("test");
string input = Console.ReadLine();
MessageBox.Show(input);
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…