,我有一个接口如何调用在类中实现的接口的方法?
public interface IMethod
{
String Add(string str);
Boolean Update(string str);
Boolean Delete(int id);
}
我宣布另一个接口就像这个 已IMethod财产。
public interface IFoo
{
IMethod MethodCaller { get ; set; }
}
现在我去了我的IFoo接口在我的类之一,我想从中调用IMethods方法。
类实现
public MyClass : IFoo
{
public IMethod MethodCaller{ get ; set; }
}
我该怎么做呢?我如何调用添加更新从MyClass的
MyClasses实现IMethod删除方法如下:
public class foo1:IMethod
{
public String Add(string str){ return string.Empty;}
Boolean Update(string str){//defination}
Boolean Delete(int id){ //defination}
}
public class foo2:IMethod
{
public String Add(string str){ return string.Empty;}
Boolean Update(string str){//defination}
Boolean Delete(int id){ //defination}
}
?什么是实现IMethod的类?你的MyClass只实现IFoo。 –