[Solved] Method must declare a body?


The error message tells you exactly what’s wrong:

‘StringedMusInsApp.Guitarra.Main(string[])’ must declare a body because it is not marked abstract, extern, or partial.

Look at your method declaration for Main(string[]):

public static void Main (string[] args);

There’s no method body. But since it’s not an abstract, extern, or partial method, it requires a method body. Define one:

public static void Main (string[] args)
{
    // do something here
}

Also note that if you don’t do anything in the Main(string[]) method then your application won’t do anything. It’ll just open and close immediately without ever executing any code. The Main(string[]) method is the entry point for the application.

This would probably become easier for you to structure if you separate your application host code (the entry point, Main(string[]), basically the stuff that executes the program) from your logic code (the Guitarra class, any business logic related to what you’re doing, and so on). For something this small it’s not necessary to break them apart into their own assemblies or use DI or anything like that, but they should at least be their own classes.

8

solved Method must declare a body?