Need Help With C Sharp

I’m using this tutorial to learn how C#, and I copy the code from the tutorial into my repl but I get the same error:

CSC : error CS1555: Could not find 'Program' specified for Main method [/home/runner/C/main.csproj]

The build failed. Fix the build errors and run again.
exit status 1

Here’s the repl:

This is the tutorial I was using:

Please help me fix this problem. I am completely new to C#.

Replit is probably set up differently than w3schools. I recommend comparing the replit template to the w3schools code and finding what is wrong.

Remove the namespace, and your code should work:
repl link here

Replit only runs the static void main method in theProgram class. It cannot be in a namespace, and this is because of the main.csproj file which says what file to run.

Learn more: Cannot select Main Method as Startup object in Visual Studio Express 2010? - Stack Overflow


in fact, if you remove line 6 from the .csproj file, you can have the program just like this

System.Console.WriteLine("Hello, World!");
1 Like

4 posts were split to a new topic: What is the C# version on replit, and how to change it?