我的Visual Studio中没有Program.cs.我如何得到它? [英] I dont have Program.cs in my Visual Studio. How do i get it?

查看:1703
本文介绍了我的Visual Studio中没有Program.cs.我如何得到它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

在我的Visual Studio Express 2013桌面版中,我找不到文件:

In my Visual studio express 2013 for desktop, I cant find the file: 

Program.cs:在我的解决方案资源管理器中.当我创建一个新项目时.

Program.cs: in my Solution explorer. When i make a new project.

并获取控制台应用程序.没有可供选择的program.cs.

And take console application. There is no program.cs i can choose.

我的视觉工作室的图片:https://gyazo.com/169d993fc877e21dbbd441c0ec733ab4

Picture of my visual studio: https://gyazo.com/169d993fc877e21dbbd441c0ec733ab4

关于维尔茨托


推荐答案

您好Werzto,

在控制台应用程序中,Program.cs不是必需的. Visual Studio为您创建一个具有Main()方法的默认Program.cs,您可以在创建项目后立即运行该应用程序.您只需要一个入口点.并用于控制台应用程序 这是Main()方法.

Hi Werzto,

In your Console Application Program.cs is not mandatory. Visual Studio creates a default Program.cs with a Main() method for you, and you are able to run the application just after creating project. You only need an entry point. And for console application it is the Main() method.

因此您可以执行以下操作:

So you can do this:

  • 在Solutin Explorer中右键单击您的项目->
  • 添加->
  • 类->
  • 为其命名为"MainProgram.cs"或其他内容->
  • 打开名为MainProgram.cs的新类,然后
  • Right click on your Project inside of Solutin Explorer ->
  • Add ->
  • Class ->
  • Give it a name "MainProgram.cs" or something else ->
  • Open new Class named MainProgram.cs and than

在MainProgram类的内部插入Main()函数:

Insert Main() function inside of MainProgram Class:

class MainProgram {

        static void Main(string[] args) {

            Console.WriteLine("Hello World");
            Console.ReadLine();
        }
    }

运行控制台应用程序,它应该可以正常运行...

最好的问候!
(如果这对您有所帮助,请对其投票并提出答案)

Run the Console App and that should work correctly...

Best regards!
(If this was helpful for you, vote for it and propose it as an answer)


这篇关于我的Visual Studio中没有Program.cs.我如何得到它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆