简体   繁体   中英

Adding and using a console application to a windows form project

I have a windows form application that picks a bunch of random numbers and then displays them. I have edited the 'Matrix Effect' console application to serve as a kind of animation for picking the numbers. I have added the console application to my random number picking project but how do I now use it?

Instead of using textbox.text you have to get input as console.readline and to display some message you have to write console.writeline . This is simple thing which is different in console application otherwise everything else is same and logics also don't need to be changed :)

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(); 

I think so this should work if yes then please rate the answer :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM