Search code examples
c#winformsmessagebox

How to show message box without console or form in background?


I am new to programming (c#). I have seen in VBScript we can show the message box (standalone). I would like to do the same in C#, just for learning, but the code when executed shows a Console or Form in the background along with a messagebox. Is it possible to only show the messagebox when the program is executed?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            MessageBox.Show("My message");
        }
    }
}

Solution

  • For Console projects, you can hide the console as follows:

    • Right click the project in the Solution Explorer
    • Select Properties
    • Go the the Application tab in the project properties.
    • Change the Output Type combo box from "Console Application" to "Windows Application".