有人可以说明自己在实时项目中使用界面的实例吗? [英] Can someone illustrate instances where they have used interfaces in real time projects by themselves.

查看:161
本文介绍了有人可以说明自己在实时项目中使用界面的实例吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道接口的用途,但是我无法实时了解它们的用途.请说明一些情况.

我尝试过的事情:

了解Dan Wahlin的C#接口和多态行为 [ ^ ]
.net-C#接口-重点是什么? -堆栈溢出 [ ^ ]

I know the purpose of Interfaces, but I am unable to figure out their usage in real time. Please illustrate some scenarios.

What I have tried:

Understanding C# Interfaces and Polymorphic Behavior by Dan Wahlin[^]
.net - C# interfaces - What''s the point? - Stack Overflow[^]

推荐答案

请参见此处:foreach语句的迭代器.如果不是,那就不能.通过实现,您可以访问可用于foreach循环的类的俱乐部".

如果您了解目的,则应该了解用法.您确定您正确理解它们吗?
See here: IEnumerable Interface (System.Collections)[^] - this is a "classic" example of an Interface; if your class implements it, it can be used as the iterator for a foreach statement. If it doesn''t it can''t. Implementation allows you access to the "club" of classes that can be used for a foreach loop.

If you understand the purpose, you should understand the usage. Are you sure you understand them properly?


这篇关于有人可以说明自己在实时项目中使用界面的实例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆