I am currently reading the Microsoft Official Course books for C# programming, the first concept they introduce you to is Console.WriteLine
The actual code they give you to type is:
class Hello
{
public static void Main()
{
Console.WriteLine("Hello, World");
}
}
I am not sure whether I am supposed to place this code under Form Load or using System because I always get the following error(s) and I am not sure what it implies:
Error ...Debug\WindowsFormsApplication1.exe' has more than one entry point defined: 'Hello.Main()'. Compile with /main to specify the type that contains the entry point.**
That is code for a console
application, not a WinForm
application. In Visual Studio, create a new project and select Console Application
as the project type.
You'll notice that a new console project will have most of the code you've got written for you (e.g. the Main
method)
The reason you were getting that error was because WinForm already has a Main
method in Program.cs
. The Main method is known as the entry point and .net standalone exe projects have one. You can make the entry point another method but this is rarely done as there's no real need to in the majority of cases.
You have the wrong application type.
The course probably mentions somewhere that you should create a new Console Application
. You have chosen Windows Forms
in your attempt.
Try creating a new Console Application
, and the Main
method will already be defined for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With