我的通用接口定义如下:
interface INewRegionBoarding<T> where T: class
{
bool Create(T objectName);
bool ValidateData(T objectName);
}
然后,我有一个实现它的类:
public class ESafeActionService<T>: INewRegionBoarding<T>
{
public bool ValidateData(EsafeActons eSafe)
{
if (String.IsNullOrEmpty(eSafe.Corporation)) return false;
if (String.IsNullOrEmpty(eSafe.Region))
{
return false;
}
else if (eSafe.Region.Length != 2)
{
return false;
}
return true;
}
public bool Create(EsafeActons eSafe)
{
return eSafe.Create(eSafe.Corporation, eSafe.Region, eSafe.PortfolioName);
}
}
构建它时,我有以下错误:
'ESafeActionService<EsafeActions>' does not implement interface member INewRegionBoarding<EsafeActions>.ValidateData(EsafeActions)'
这是ESafeAction
类定义:
公共类EsafeActons {
private string corporation;
private string region;
private string portfolioName;
public EsafeActons(string corporation, string region, string portfolioName)
{
this.corporation = corporation;
this.region = region;
this.portfolioName = portfolioName;
}
public string Corporation
{
get { return this.corporation; }
set { this.corporation = value; }
}
public string Region
{
get{return this.corporation;}
set { this.region = value; }
}
public string PortfolioName
{
get { return this.corporation; }
set { this.portfolioName = value; }
}
public bool Create(string corporation, string region, string portfolioName)
{
//call stored proc
return true;
}
}
我不确定我做错了什么。
感谢的
答案 0 :(得分:2)
我不确定我做错了什么
您保持该类的通用性,但实现具有特定类型的接口。将您的班级定义更改为:
public class ESafeActionService: INewRegionBoarding<EsafeActons>
{