Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Basics Extending Our Entity Data Model Defining and Using a One-to-Many Relationship

Andre Martins
Andre Martins
1,629 Points

error CS1520: on "public Courses()", Return Type needed but can´t figure out why...

I'm following the Comic Book example, my code follow the video guidelines but can´t figure out what´s wrong @ line 7: public Courses() { ... }. The video do not have a return type in the same public Series() method.

1 Answer

Steven Parker
Steven Parker
231,268 Points

You forgot to include your code in the question, but I'll guess that you're trying to create a default constructor for the class "Course" but naming it "Courses". This would cause the error you are seeing because the different name (with an "s") would be seen by the compiler as a normal method (which requires a return type) and not a constructor.

Constructors must have the same name as the class, so removing the "s" and renaming it "Course" will probably resolve the issue.

For future questions, or if this doesn't fix the issue, be sure to include your code with the question.