0
我有几个类插入相同的接口。我将接口传递给一个方法。我正在试图通过什么课程。例如,这里有一些类我可能有:从接口获取类名
internal class SomeClassName : MyInterface
internal class SomeOtherName : MyInterface
internal class NotReallySure: MyInterface
internal class NewClassName: MyInterface
internal class SomethingSpecial: MyInterface
这里是方法:
public void ProcessClass(MyInterface myInterface)
我有什么企图?我试过这个,但它不起作用
if (myInterface.GetType() == NotReallySure)
{
//
}
那么我究竟在做什么?
我想检查的“MyInterface的”值等于某一类名或更好类值
那样? http://stackoverflow.com/questions/3561202/check-if-instance-of-a-type – Marvin