# C# Compiler Error

This topic is 2554 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Program '...\Shakespeare.exe' does not contain a static 'Main' method suitable for an entry point.

using System; public class Shakespeare { public static void Main() { Console.WriteLine("Though this be maddness"); Console.WriteLine("yet there is method in it"); Console.WriteLine("-William Shakespeare"); } }

I want to study C#, but I get an error from the compiler saying that I don't have a static Main method, when its right in front of my face. I'm using Visual Studio 2008. Anything I might be doing wrong?

##### Share on other sites
Seeing the using System; line there, I take it that this is your whole code, right? No Namespace?

Try something like this:
using System; namespace Program1 { public class Shakespeare { public static void Main() { Console.WriteLine("Though this be maddness"); Console.WriteLine("yet there is method in it"); Console.WriteLine("-William Shakespeare"); } } } 

Mainly, just putting everything you had so far, inside a namespace scope.
Did you write this by hand by the way? Since using the new project option in VS it should've set that for you.

I hope that that's the issue, and not me missing something for misinterpreting =)

Welcome to programming.

##### Share on other sites
Nope. Still not working, and it's giving the same error.

##### Share on other sites
I'm sorry mate, I'm not really fluent with C# by heart, I use it at work, but at home I prefer C++ myself, so I'm not very positive on the syntaxing.

I do suggest again that you use the project creation wizard in Visual Studio, and not write the template by hand, if you didn't do so already.

##### Share on other sites
T_T Maybe I should just go back to learning C++ then. The only thing I can imagine doing with C# is using XNA, unless somebody else wants to take a crack at my error.

##### Share on other sites
Iunno, I wouldn't do that if I were you.
It seems that you're very new to programming in general, right?

C# is really easier to get into and learn than C++ is, and XNA is far superior in learnability to newcomers than the competing alternatives for C++(SDL and SFML topping the mind), not to even mention how much simpler .NET is for C# than C++.

C# is very much superior for beginners, and I wouldn't turn down on it for just one compiling error that I'm sure someone will help you fix very soon anyway. Take in mind that programming requires patience after all =P

##### Share on other sites
I created a new Windows console project; commented out the generated code; and copy and pasted your code. Built without debugger (Ctrl+f5 for me).

Worked fine.

Just a few ideas...
1. Try creating a new project and copy/paste your code into it. Maybe a setting got messed up.
2. Rebuild the whole solution. Weird things happen to me and this fixes it sometimes (from menu, Build ->Rebuild Solution and the shortcut is set to Ctrl+Alt+F7 on mine)

##### Share on other sites

T_T Maybe I should just go back to learning C++ then. The only thing I can imagine doing with C# is using XNA, unless somebody else wants to take a crack at my error.

Compiler errors should never be a reason to switch languages.

Perhaps this Stackoverflow thread can help?

##### Share on other sites

[quote name='Philosogamer' timestamp='1324327268' post='4895448']
T_T Maybe I should just go back to learning C++ then. The only thing I can imagine doing with C# is using XNA, unless somebody else wants to take a crack at my error.

Compiler errors should never be a reason to switch languages.

Perhaps this Stackoverflow thread can help?
[/quote]

Nah. His program is less basic than mine. I don't have a GUI, and when I went into the options to see if I could change the Startup object, there were no options on the drop down menu.

And im totally kidding when I say I'm gonna give up for 1 stupid error. XD

##### Share on other sites
That compiles for me fine in Visual Studio 2010 using a C# Console Application from the default menu.

1. 1
2. 2
Rutin
21
3. 3
A4L
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013603
×