Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Abstract class' constructor asks for a return type

I don't understand what's happening here, I've copied this code from another project (which compiled without problems), but as soon as I got it into my own, I got a compiler error on the constructor definition saying the method needs a return type.

public abstract class BaseSqlRepository<T, InterfaceT, PrimaryKeyT>
        where T : class
        where InterfaceT : class
{
    protected EvalgridEntities DataContext;
    protected BaseSqlRespository(EvalgridEntities db)
    {
        this.DataContext = db;
    }
}

Method must have a return type.

What am I missing?

like image 224
Kenji Kina Avatar asked Dec 22 '22 01:12

Kenji Kina


1 Answers

You misspelled it. Your constructor is spelled BaseSqlRe sp ository.

Change to:

protected BaseSqlRepository(EvalgridEntities db)
{
    this.DataContext = db;
}

Since the naming is different, the compiler sees this as a method, not a constructor. Since there is no return type, you get the error:

Method must have a return type.

like image 186
Reed Copsey Avatar answered Jan 05 '23 03:01

Reed Copsey