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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
MuthuMari MRank #5,738 · 288 reputationPosted Apr 8, 2012, 8:28 PM EDT
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"
Keyur Narkhi62 reputationPosted Apr 8, 2012, 8:49 PM EDT
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.
Lars Persson91 reputationPosted Apr 9, 2012, 2:06 AM EDT
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.
SenthilkumarRank #387 · 6.5K reputationPosted Apr 9, 2012, 4:07 AM EDT
(Referred from MSDN)
The same you can refer in the following:
http://msdn.microsoft.com/en-us/library/sf985hc5(v=vs.71).aspx
lakshmipathi vemula20 reputationPosted Apr 10, 2012, 10:00 PM EDT
This will explain you about Abstract classes in c#.NET
Link:http://www.bestdotnettraining.com/Online/Training/CSharp/Inheritance/6