mizuprogrammer
mizuprogrammer

Reputation: 265

C# basic hello world not running

New ErrorOutput from code when ran

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. 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!!

Upvotes: 3

Views: 7390

Answers (2)

vernou
vernou

Reputation: 7590

As @canton7 say, this code don't compile, then you run a old compiled version.

You can change this behavior in Tools -> Options : enter image description here

Upvotes: 1

psj01
psj01

Reputation: 3245

Your main method inside class Program should be a static method. - This is your entry point.

Add the static keyword to your main method.

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

Upvotes: 6

Related Questions