什么是抽象类和静态之间的差异? [英] What's the difference between an abstract class and a static one?

查看:119
本文介绍了什么是抽象类和静态之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论是实例化。有什么区别,以及在什么情况下可以使用一个或其他?

Neither is instantiable. What are the differences, and in what situations might you use one or the other?

推荐答案

静态表示该类只能有静态成员,你不能建立它的一个实例。这是用于无状态的功能(例如,仅仅定义扩展方法,或实用方法的类型)。您也可以声明静态在非静态类成员。这可以让你附加功能的一类,而不必实例化。

static indicates the class can only have static members and you cannot create an instance of it. This is used for stateless functionality (for example a type that just defines extension methods, or utility methods). You can also declare a member static on a non-static class. This allows you to attach functionality to a type without having to instantiate it.

下面是使用静态成员和类更多细节。

抽象取值定义的基本结构和功能的所有衍生物类型的共享,但不能使用由自己决定。把它们当作我想,一个蓝色的印刷和合同。这是OOP的一个核心概念。

abstracts define the basic structure and functionality shared by all derivative types, but cannot be used by themselves. Think of them as, I suppose, a blue print and a contract. This is a core concept for OOP.

下面详细使用摘要

这篇关于什么是抽象类和静态之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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