且构网

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

从集合中调用接口方法

更新时间:2023-12-03 22:44:52

您不能直接使用.

您可以做的是通过在此自定义集合中实现本地接口来创建自己的ObservableCollection.
然后,您可以使用上面编写的代码.
You cannot directly.

What you can do is create your own ObservableCollection by implementing your local interface in this customized collection.
You can then use the code you have written above.


我可以为您提供一个很好的健壮替代方案:我的DynamicMethodDispatcher通过键调度委托调用.这是一种非常有效的方法.您将获得完整的源代码和用法示例.请参阅我的文章动态方法分派器 [
I can offer your a good robust alternative: my DynamicMethodDispatcher which dispatches a delegate call by key. This is quite powerful and effective approach. You will get full source code and usage samples. Please see my article Dynamic Method Dispatcher[^].

—SA


您不能调用"接口方法,因为它们没有实现任何东西.
这就是所谓的实现接口的原因.

如果Employee类实现了接口IPerson,则Employee将必须实现IPerson中定义的所有功能,但是不知道它是否有意义.

您应该阅读一些有关Interfaces的信息:
http://msdn.microsoft.com/en-us/library/ms173156.aspx [ ^ ]

希望对您有帮助
You can''t ''call'' Interface methods since they don''t implement anything.
That''s why it''s called implementing an interface.

If a class Employee implements an Interface IPerson, then Employee will have to implement all the functions defined in IPerson, don''t know it it makes sense though.

You should read a little about Interfaces:
http://msdn.microsoft.com/en-us/library/ms173156.aspx[^]

Hope it helps