楼上说的很清楚了 public class Question : IQuestion { public IList <QuestionAllotInfo> GetListByAdminId(int adminId) { IList <QuestionAllotInfo> list = new List <QuestionAllotInfo>(); using (NullableDataReader reader = DBHelper.ExecuteReaderSql("SELECT * FROM ADMIN WHERE AdminID = @AdminID ", new Parameters("@AdminID", DbType.Int32, adminId))) { while (reader.Read()) { list.Add(GetInfoFormReader(reader)); } } return list; } } public interface IQuestion { IList <QuestionInfo> GetListByAdminId(int adminId); }
上边这个问题中类型写错了: public class QuestionInfo {
public int AdminId { get; set; } public string AdminName { get; set; } } public interface IQuestion { IList <QuestionInfo> GetListByAdminId(int adminId); } public class Question : IQuestion { public IList <QuestionInfo> GetListByAdminId(int adminId) { IList <QuestionInfo> list = new List <QuestionInfo>(); using (NullableDataReader reader = DBHelper.ExecuteReaderSql("SELECT * FROM ADMIN WHERE AdminID = @AdminID ", new Parameters("@AdminID", DbType.Int32, adminId))) { while (reader.Read()) { list.Add(GetInfoFormReader(reader)); } } return list; } } 编译时提示以下错误,不知是何问题,高手指教! “Question”不会实现接口成员“IQuestion.GetListByAdminId(int)”。“Question.GetListByAdminId(int)”或者是静态、非公共的,或者有错误的返回类型。
public class Question : IQuestion
{
public IList <QuestionAllotInfo> GetListByAdminId(int adminId)
{
IList <QuestionAllotInfo> list = new List <QuestionAllotInfo>();
using (NullableDataReader reader = DBHelper.ExecuteReaderSql("SELECT * FROM ADMIN WHERE AdminID = @AdminID ", new Parameters("@AdminID", DbType.Int32, adminId)))
{
while (reader.Read())
{
list.Add(GetInfoFormReader(reader));
}
}
return list; }
}
public interface IQuestion
{
IList <QuestionInfo> GetListByAdminId(int adminId);
}
public class QuestionInfo
{
public int AdminId { get; set; }
public string AdminName { get; set; }
} public interface IQuestion
{
IList <QuestionInfo> GetListByAdminId(int adminId);
}
public class Question : IQuestion
{
public IList <QuestionInfo> GetListByAdminId(int adminId)
{
IList <QuestionInfo> list = new List <QuestionInfo>();
using (NullableDataReader reader = DBHelper.ExecuteReaderSql("SELECT * FROM ADMIN WHERE AdminID = @AdminID ", new Parameters("@AdminID", DbType.Int32, adminId)))
{
while (reader.Read())
{
list.Add(GetInfoFormReader(reader));
}
}
return list;
}
}
编译时提示以下错误,不知是何问题,高手指教! “Question”不会实现接口成员“IQuestion.GetListByAdminId(int)”。“Question.GetListByAdminId(int)”或者是静态、非公共的,或者有错误的返回类型。