简体   繁体   English

C#基本的hello world没有运行

[英]C# basic hello world not running

新错误 运行时代码的输出

I am just trying to run a basic hello world program (or any program for that matter) and no matter what I do I always get this cmd terminal that pops up (even if I don't use Console.out.write() or any code at all) when I hit any key to continue the terminal closes and my code never runs.我只是想运行一个基本的 hello world 程序(或任何与此相关的程序),无论我做什么,我总是会弹出这个 cmd 终端(即使我不使用 Console.out.write() 或任何代码)当我按任意键继续终端关闭并且我的代码永远不会运行。 Please any help would be greatly appreciated I can't seem to find anybody else having this issue.请任何帮助将不胜感激我似乎找不到其他人有这个问题。 I've attached a picture of the code used as well as the terminal that pops up (basically a screenshot of what happens after I click run).我附上了所用代码的图片以及弹出的终端(基本上是单击运行后发生的情况的屏幕截图)。

Edit: I changed it to static and am now receiving this error, I placed it in a brand new project and everything there is no other files so not sure why I'm getting this, thank you all for the help!!编辑:我把它改成静态的,现在收到这个错误,我把它放在一个全新的项目中,所有的东西都没有其他文件,所以不知道为什么我会得到这个,谢谢大家的帮助!!

Your main method inside class Program should be a static method.您在 Program 类中的 main 方法应该是一个静态方法。 - This is your entry point. - 这是您的切入点。

Add the static keyword to your main method.将 static 关键字添加到您的 main 方法中。

static void Main(string[] args)
{
    Console.WriteLine("Hello World!");
    Console.ReadLine();
}

As @canton7 say, this code don't compile, then you run a old compiled version.正如@canton7 所说,这段代码不能编译,然后你运行一个旧的编译版本。

You can change this behavior in Tools -> Options :您可以在 Tools -> Options 中更改此行为: 在此处输入图片说明

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

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