stay Qt in , Frequently used qDebug()<<"Hello World"; To print some output to the console , In order to observe the operation of the program .
stay Java in (eclipse,myeclipse in ), What is often used is System.out.println("Hello World"); The way .
stay Android in , What is often used is Log.d("Hello World");
. .
stay C# When , Using Console.WriteLine("Hello World");
development winform When , The following main function needs to be added to the file .
Lead into storage :
using System.Runtime.InteropServices;
stay Main() Front , add to :
[DllImport("kernel32.dll")]
public static extern bool AllocConsole();
[DllImport("kernel32.dll")]
static extern bool FreeConsole();
stay Main() in , First line added :
AllocConsole();
stay Main() in , Add last line :
FreeConsole();
Examples :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
// console output , Need to join this library
using System.Runtime.InteropServices;
namespace HelloWorld_WindowsForm
{
static class Program
{
[DllImport("kernel32.dll")]
public static extern bool AllocConsole();
[DllImport("kernel32.dll")]
static extern bool FreeConsole();
/// <summary>
/// The main entry point for the application .
/// </summary>
[STAThread]
static void Main()
{
// Allow calling console output
AllocConsole();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LoginPage());
// release
FreeConsole();
}
}
}
Reward QR code :
Technology