I have not used Win Core.
Note: Think
carefully before using a technique like this ... many users are socialized to expecting a Console App to not use MessageBox, or show Forms !
1) add using System.Windows.Forms; to your Console App.
1a) add a Form to your Console App Project. Put a TextBox and a Button on the Form.
2) example Console App
using System;
using System.Windows.Forms;
namespace ConsoleAppWithForm
{
class Program
{
static void Main(string[] args)
{
Form1 f1 = new Form1();
string data = null;
f1.TransferData = s => data = s;
DialogResult dresult = f1.ShowDialog();
f1.Dispose();
Console.WriteLine($"result: {dresult} | value entered: {data}");
Console.ReadKey();
}
}
}
3) example Form
using System;
using System.Windows.Forms;
namespace ConsoleAppWithForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Action<string> TransferData;
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != String.Empty && TransferData != null)
{
TransferData(textBox1.Text);
this.DialogResult = DialogResult.OK;
}
else
{
this.DialogResult = DialogResult.Cancel;
}
this.Close();
}
}
}