【发布时间】:2016-05-11 04:48:57
【问题描述】:
界面:
public interface IArrayOperation
{
int GetElement(int index);
bool IndexCheck(int index);
}
静态类:
public static class TestArray
{
public static int GetArrayLength(IArrayOperation arrayOperation)
{
// Implement your logic here.
// I need to implement interface method over here.
throw new NotImplementedException();
}
}
这里,我想在静态类方法GetArrayLength()中实现这两个接口方法。
我不想实现接口,但是我已经在静态类方法中将接口作为参数传递了。
感谢任何帮助或指导。
【问题讨论】:
-
谢谢斯图亚特。你是对的。我想通过接口方法获取静态类中的虚拟数组长度。
-
@Stuartd 你为什么重新打开这个问题,它显然是引用的重复?
-
您必须将实现
IArrayOperation的类的实例传递给GetArrayLength。 -
“我想实现这两种接口方法……我不想实现接口”哪个?
标签: c# .net inheritance interface