你可以修改抽象类和interface.if修改是可能的,否则为什么不允许 [英] can u modify the abstract classes and interface.if modification is possible why allowed otherwise why not allowed

查看:74
本文介绍了你可以修改抽象类和interface.if修改是可能的,否则为什么不允许的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   我在c#.i中读到了有关接口和抽象类的信息,有疑问 关于接口和抽象类的修改。

   i read about interfaces and abstract classes in c#.i have doubt  about modification in interfaces and abstract classes.

如果两个概念都可以修改,为什么修改允许,否则为什么不允许修改

if modification is possible in both concepts why modification allowed otherwise why modification is not allowed

推荐答案

" 有疑问 关于界面中的修改  

您必须更加具体。 

You're going to have to be more specific. 

界面是只是两段代码之间的契约,澄清了1件将提供的功能以及另一件可以使用的功能。您不能在不使两段代码无效的情况下更改合同。因此,您通常不会修改接口。

An interface is just a contract between 2 pieces of code that clarifies what functionality 1 piece will provide and what the other can use. You cannot alter a contract without invalidating both pieces of code. As such you generally don't modify interfaces.

抽象类提供了部分实现。派生类可以添加其他功能。抽象类是首选,因为可以添加新功能而不会破坏任何现有代码。也可以进行更改,但可能或
可能会使现有代码无效。

Abstract classes provide a partial implementation of something. Derived classes can add additional functionality. Abstract classes are preferred because new functionality can be added without breaking any existing code. Changes can also be made but may or may invalid existing code.


这篇关于你可以修改抽象类和interface.if修改是可能的,否则为什么不允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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