且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

执行C#接口

更新时间:2023-02-07 19:06:24

但是!!!接口方法如何执行??
BUT!!!....how does the interface methods get executed???

接口不具有方法的实现,而仅定义合同.因此,接口方法将无法执行,因为按照接口的定义,它就不需要执行.

但是,如果您创建一个实现接口定义的协定的对象,则您可以像调用其他方法一样通过调用该方法在派生对象中执行创建实现.

您可以参考本文以获得更多帮助:http://msdn.microsoft.com/en-us/library/87d83y5b%28VS.71%29.aspx

An interface does not have an implementation of methods, but rather just defines a contract. Therefore it would be impossible for a interface methods to get executed because by the very definition of an interface it has nothing to execute.

However if you create an object that implements the contract defined by the interface, then you could execute the implementation create in your derived object by calling the method like you would any other method.

You may refer to this article for further assistance: http://msdn.microsoft.com/en-us/library/87d83y5b%28VS.71%29.aspx