扩展方法是C#的面向对象功能吗? [英] Are extension methods an object-oriented feature of C#?

查看:91
本文介绍了扩展方法是C#的面向对象功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

扩展方法是否遵循C#中的面向对象范例?

Do extension methods follow the object-oriented paradigm in C#?

使用扩展方法是一种好习惯吗?

Is it a good practice to use extension methods?

在软件开发生命周期中,我们应如何在设计阶段考虑这个问题?

In the software development lifecycle how should we consider this question in the design phase?

推荐答案

扩展方法不是面向对象的语言功能。 (相比于:类,继承,多态等)。

Extension methods are not an object oriented language feature. (compared to: classes, inheritance, polymorphism etc).

就像每种语言功能一样,应在适当的地方使用它,并针对其设计用途。关于何时以及如何使用扩展方法已经存在许多问题。

Like every language feature, it should be used where it is appropriate and for what it is designed for. There are already dozens of questions about when and how to use Extension methods.

  • What are the best practices for using Extension Methods in .Net?
  • Possible overuses of Extension Methods
  • Do Extension Methods Hide Dependencies?

这篇关于扩展方法是C#的面向对象功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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