Recently begun to learn C#. One of the tasks contain the example, which I haven't been able to release. Here it is.
using System.Windows.Forms;
class ShowForm
{
public static void Main()
{
MessageBox.Show("Windows Forms!");
MessageBox.Show("Windows Forms with title", "title");
if (MessageBox.Show("Are you sure I want to continue?", "title",
MessageBoxButtons.OKCancel) == DialogResult.OK)
System.Console.WriteLine("You pressed OK");
else System.Console.WriteLine("You pressed Cancel");
System.Console.WriteLine("You can show messages in Console as well");
System.Console.ReadKey();
}
}
The error it shows is: System.InvalidOperationException: "Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read." I've tried to change preferences in the solution, but it didn't help. Would be thankful for any advise.