简体   繁体   English

如何在后台没有控制台或窗体的情况下显示消息框?

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

I am new to programming (c#). 我是编程(c#)的新手。 I have seen in VBScript we can show the message box (standalone). 我在VBScript中看到过,我们可以显示消息框(独立)。 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. 我想在C#中这样做,只是为了学习,但是执行时的代码在后台显示控制台或窗体以及消息框。 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");
        }
    }
}

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". 将“ 输出类型”组合框从“控制台应用程序”更改为“ Windows应用程序”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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