What’s wrong with my function? C# [closed]

The first error can help you search for “C# methods”, which will lead you to this:

Methods are declared in a class or struct by specifying the access level such as public or private, optional modifiers such as abstract or sealed, the return value, the name of the method, and any method parameters. These parts together are the signature of the method.

The error says:

must have a return type

Searching “return type” on that page gives you:

If the return type, the type listed before the method name, is not void, the method can return the value by using the return keyword.

So between the access modifier “public” and the method name “PlayerCards” you need a “return type”: string. It’s all about definitions. If you get those, the compiler is really helpful with its errors.

Leave a Comment