Hi friends,
I want to know that why do we make a class an abstract? What are the benefits to do that please explain in programming scenario?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
lakshmipathi vemulaPosted Apr 11, 2012, 2:00 AM
This will explain you about Abstract classes in c#.NET
Link:http://www.bestdotnettraining.com/Online/Training/CSharp/Inheritance/6
SenthilkumarPosted Apr 9, 2012, 8:07 AM
(Referred from MSDN)
The same you can refer in the following:
http://msdn.microsoft.com/en-us/library/sf985hc5(v=vs.71).aspx
Lars PerssonPosted Apr 9, 2012, 6:06 AM
From that class you can let other classes inherit.
You can make a Car-class, Truck-Class, Bus-class etc.
The thing is, that nothing is only a vehicle, it is always some kind of vehicle.
So it makes no sense in creating an object of type vehicle.
That´s why you make it abstract, so you can´t create any objects of it.
Keyur NarkhiPosted Apr 9, 2012, 12:49 AM
Abstract classes are one,in which you can not create the object of that class.And you can create the abstract method which needs to override into your child classes.
When you need to define common behavior ,you can go with abstract class.
Please follow this url
http://www.c-sharpcorner.com/UploadFile/rajeshvs/AbstractClassesNMethods11122005014357AM/AbstractClassesNMethods.aspx
Hope this helps.
MuthuMari MPosted Apr 9, 2012, 12:28 AM
Abstract classes cannot be used to instantiate objects; because abstract classes are incomplete, it may contain only definition of the properties or methods and derived classes that inherit this implements it's properties or methods.
pls refer this url for samples.
http://en.csharp-online.net/Interfaces_and_Abstract_Classes
http://msdn.microsoft.com/en-us/library/sf985hc5%28v=vs.71%29.aspx
thanks.
If this post is useful then mark it as "Accepted Answer"