Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 985
mizuprogrammer Avatar asked May 24 '26 19:05

mizuprogrammer


1 Answers

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();
}
like image 148
psj01 Avatar answered May 27 '26 08:05

psj01



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!