Introduction
Abstraction class is a special class that can't be instantiated. Abstraction class is used in ASP.net (c#) as a result of ASP.net has not multiple inheritances thus we will use abstraction classes as an alternative. Abstraction is inheritable through sub classes, functions, forms etc. It's alternate to use multiple inheritances in ASP.net. Abstract will use its completely different modifiers specifies however in abstraction class this feature isn't enclosed in interface class. Abstraction class is quicker than interface class. Abstraction have implementation in class also. If we have to use common behaviour in our class then abstract class is better option. We can define abstract class with keyword Abstract class. If you are planning smaller units then use interface class if you use design large units of functions then use abstract class.public abstract class TestClass { // Class members can define here. }Abstract class can also defines abstract methods also. I have given very good example as given below.
public abstract class TestClass { public abstract void DoTestwork(int j); }
Abstract class have not implementation. Abstract class can override its methods from base class. When a abstract class inherits methods from its base class, abstract class can overrides its virtual methods class methods. I have provided a very good example for the same.
public class Test { public virtual void DoSampleMethod(int j) { // Original implementation. } } public abstract class TestNew : Test { public abstract override void DoWork(int i); } public class Funny : TestNew { public override void DoSampleMethod(int j) { // New implementation. } }
Post A Comment:
0 comments: