Reputation: 2108
I have a generic interface defined as following:
interface INewRegionBoarding<T> where T: class
{
bool Create(T objectName);
bool ValidateData(T objectName);
}
Then, I have a class implementing it:
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);
}
}
When building it, I have the following error:
'ESafeActionService<EsafeActions>' does not implement interface member INewRegionBoarding<EsafeActions>.ValidateData(EsafeActions)'
This is the ESafeAction
class definition:
public class 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;
}
}
I'm not really sure what I'm doing wrong.
Thank's
Upvotes: 0
Views: 507
Reputation: 152634
I'm not really sure what I'm doing wrong
You're keeping the class generic but implementing the interface with a specific type. Change your class definition to:
public class ESafeActionService: INewRegionBoarding<EsafeActons>
{
Upvotes: 2