普通类和抽象类之间的区别 [英] Difference between normal class and abstract class

查看:81
本文介绍了普通类和抽象类之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

普通类和抽象类之间的区别







在Asp中使用MVC的用法。净......



i更新鲜告诉我的朋友

Difference between normal class and abstract class

and

what use of MVC in Asp.Net......

i am a fresher plese tell me friends

推荐答案

A class 是一种结构,它允许您通过将其他类型,方法和事件的变量分组在一起来创建自己的自定义类型。一个类就像一个蓝图。它定义了类型的数据和行为。如果该类未声明为静态,则客户端代码可以通过创建分配给变量的对象或实例来使用它。变量保留在内存中,直到对它的所有引用都超出范围。那时,CLR将其标记为有资格进行垃圾收集。如果该类声明为静态,则内存中只存在一个副本,客户端代码只能通过类本身访问它,而不是实例变量。



类定义中由关键字abstract标记的抽象类通常用于在层次结构中定义基类。它们的特殊之处在于,您无法创建它们的实例 - 如果您尝试,您将收到编译错误。相反,您必须对它们进行子类化,并创建子类的实例。那么你什么时候需要一个抽象类呢?这取决于你做了什么。



课程(C#) [ ^ ]

https://msdn.microsoft.com/en-IN/library/ms173150.aspx [ ^ ]

所有关于抽象类的内容。 [ ^ ]

http://www.dofactory.com/topic/1311/why-do- we-need-to-use-abstract-class.aspx [ ^ ]

http://www.techotopia.com/index.php/ Understanding_C_Sharp_Abstract_Classes [ ^ ]

http://www.dotnetperls.com/abstract [ ^ ]



并且在Asp.Net中使用MVC ,根本没有意义。

你需要了解ASP .NET和它之间的区别。 ASP .NET MVC。

参考: Webforms与MVC以及为什么MVC更好? [ ^ ]





-KR
A class is a construct that enables you to create your own custom types by grouping together variables of other types, methods and events. A class is like a blueprint. It defines the data and behavior of a type. If the class is not declared as static, client code can use it by creating objects or instances which are assigned to a variable. The variable remains in memory until all references to it go out of scope. At that time, the CLR marks it as eligible for garbage collection. If the class is declared as static, then only one copy exists in memory and client code can only access it through the class itself, not an instance variable.

Abstract classes, marked by the keyword abstract in the class definition, are typically used to define a base class in the hierarchy. What's special about them, is that you can't create an instance of them - if you try, you will get a compile error. Instead, you have to subclass them, and create an instance of your subclass. So when do you need an abstract class? It really depends on what you do.

Classes (C#)[^]
https://msdn.microsoft.com/en-IN/library/ms173150.aspx[^]
All about abstract classes.[^]
http://www.dofactory.com/topic/1311/why-do-we-need-to-use-abstract-class.aspx[^]
http://www.techotopia.com/index.php/Understanding_C_Sharp_Abstract_Classes[^]
http://www.dotnetperls.com/abstract[^]

And use of MVC in Asp.Net, doesn't make a sense at all.
You need to understand the difference between ASP .NET & ASP .NET MVC.
Refer this: Webforms vs MVC and Why MVC is better ?[^]


-KR

< br>

关于差异的大多数问题毫无意义。并且要求使用MVC的整个想法是错误的。这与询问在开发Web应用程序时使用氧气有什么用途相同?你会怎么回答?



请查看我过去对相关主题的回答:

当我们使用抽象时,当我们使用界面时......? [< a href =http://www.codeproject.com/Answers/163139/When-we-use-abstract-and-when-we-use-interface#answer2target =_ blanktitle =New Window> ^ ],

抽象类和接口之间的区别,如果它们具有相同的方法和变量 [ ^ ],

如何决定选择抽象类或接口 [ ^ ],

接口和多态性 [ ^ ],

没有过载和覆盖的多态性可能 [ ^ ],

对接口的怀疑 [ ^ ],

为什么我们需要为接口创建实例而不是实施? [ ^ ],

如果abstact类实现了接口,那么是否需要在抽象类中实现接口方法。 [ ^ ]。



参见:

.net如何理解类型转换 [ ^ ],

使用多态? [ ^ ]。



-SA
Most question about "difference" make no sense. And the whole idea to ask "what use of MVC" is wrong. This is the same as asking "what's the use of oxygen when you are working at development of Web application?" How would you answer?

Please see my past answers to the questions on related topics:
When we use abstract and when we use interface...?[^],
Difference between abstract class and interface if they have same no of methods and var[^],
How to decide to choose Abstract class or an Interface[^],
Interfaces and Polymorphism[^],
POLYMORPHISM WITHOUT OVERLOADING AND OVERRRIDING IS POSSIBLE[^],
Doubts on Interfaces[^],
Why we need to create instance for interface not for implementation?[^],
If abstact class implements the interface then is there any need to implement interface method in abstract class.[^].

See also:
How does .net understands about type casting[^],
The use of polymorphism ?[^].

—SA


这篇关于普通类和抽象类之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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