Ken*_*ina 4 c# constructor compiler-errors
我不明白这里发生了什么,我从另一个项目(编译没有问题)中复制了这个代码,但是一旦我把它编入我自己的,我在构造函数定义上得到一个编译器错误,说该方法需要一个返回类型.
public abstract class BaseSqlRepository<T, InterfaceT, PrimaryKeyT>
where T : class
where InterfaceT : class
{
protected EvalgridEntities DataContext;
protected BaseSqlRespository(EvalgridEntities db)
{
this.DataContext = db;
}
}
Run Code Online (Sandbox Code Playgroud)
方法必须具有返回类型.
我错过了什么?
你拼错了.你的构造函数拼写为BaseSqlRe sp ository.
改成:
protected BaseSqlRepository(EvalgridEntities db)
{
this.DataContext = db;
}
Run Code Online (Sandbox Code Playgroud)
由于命名不同,编译器将此视为方法,而不是构造函数.由于没有返回类型,您会收到错误:
方法必须具有返回类型.
| 归档时间: |
|
| 查看次数: |
1492 次 |
| 最近记录: |