抽象类和接口的实时示例 [英] realtime example for abstract class and interface

查看:55
本文介绍了抽象类和接口的实时示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能举个例子吗,一个人的任何作品或任何同情的东西都实时地认为是世界上任何要抽象类和接口的对象

Can U please to tell me a example, real time any works in a human or any compassion thinks are any objects in a world to abstract Class and interfaces

推荐答案

在现实世界与抽象类或接口之间没有任何直接比较,因为(即使在C#中)它们不是事物,它们也不能为

我能说的最接近的是文明:它之所以存在,是因为它有一套规则或法律,当我们遵守这些规则或法律时,我们就称其为文明".当我们打破它们时,我们被称为野蛮人"或野蛮人",并且不允许他们分享文明的利益.想想货币体系:如果您相信所有其他人都称其为货币"具有价值,并且同意以一定数量的货币交换商品,那么您就可以进入金融体系并可以开设一个货币体系.银行账户.相反,如果您决定金钱不再值钱,那么您将被踢出帐户,并被关闭.想一想希腊可能很快会发生什么-它使用欧元,但作为一个国家的财政状况几乎一文不值,因此可能不允许与欧元交易更长的时间.

接口定义了一个阶级必须采用的规则-如果愿意,可以采用文明定律-当它采用这些规则时,它被视为与也采用这些规则的所有其他阶级相同.只要您遵守规则,它都不会在乎如何实现它们.

Abstract类更进一步-如果您不想定义自己的类,它为您提供了一种遵循规则的默认方式.
There aren''t any direct comparisons between the real world and either an abstract class or an interface, because (even in C#) they aren''t things, they can''t be objects

The closest I can come is civilization: it exists because it has a set of rules or laws that when we obey them we are called "civilized". When we break them, we are termed "barbarian" or "outlaw" and are not permitted to share in the benefits of civilization. Think of the monetary system: if you subscribe to the belief that what all the others call "money" has a value, and you agree to exchange goods for a set amount of money, then you are allowed into the financial system and can open a bank account. If instead you decide that money is not worth your goods any more then you will be kicked out and your account will be closed. Think about what may happen to Greece fairly shortly - it uses the Euro, but it''s finances as a country are nearly worthless so it may not be allowed to play with the Euro for much longer.

An Interface defines the rules that a class must adopt - the laws of civilization if you like - and when it adopts them, it lets it be treated as the equal of every other class that also adopts those rules. It doesn''t care how you implement them, as long as you follow the rules as they are.

An Abstract class goes further - it gives you a default way to obey the rules if you do not want to define your own.


这篇关于抽象类和接口的实时示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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