首页 > 解决方案 > 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");
        }
    }
}

标签: c#winformsmessagebox

解决方案


对于控制台项目,您可以隐藏控制台,如下所示:

  • 右键单击解决方案资源管理器中的项目
  • 选择属性
  • 转到项目属性中的应用程序选项卡。
  • 输出类型组合框从“控制台应用程序”更改为“Windows 应用程序”。

推荐阅读