C# 控制台应用程序问题

C# 控制台应用程序问题,c#,.net,console-application,C#,.net,Console Application,我一直在想,为什么当我创建控制台应用程序并将主方法“转换”为与创建windows窗体项目时自动生成的主方法相同时,控制台仍然出现在屏幕上: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Globalization; using System.Windows.Forms; namespace Cha

我一直在想,为什么当我创建控制台应用程序并将主方法“转换”为与创建windows窗体项目时自动生成的主方法相同时,控制台仍然出现在屏幕上:

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

namespace Chapter16
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new CultureTest());
        }
    }
}
此代码与windows窗体应用程序的Program.cs中的代码相同。问题是控制台仍然出现在屏幕上,而windows窗体项目中的情况并非如此。为什么呢

善良的国王
PK

您应该将项目属性中的目标类型设置为“Windows应用程序”。这相当于
/target:winexe
编译器开关。它将改变二进制标题中的
子系统
,告诉Windows不要打开shell窗口。

您应该将项目属性中的目标类型设置为“Windows应用程序”。这相当于
/target:winexe
编译器开关。它将改变二进制标题中的
子系统
,告诉Windows不要打开shell窗口