- What is Abstract Class ?
- Why do we need Abstract Class ?
- We need to use abstract class when we want to follow certain hierarchy for all sub classes.
- In simple words, it is a kind of contract that forces all the sub classes to carry on the same hierarchies or standards.
- Facts About Abstract Class
- Practical Example For Abstract Class using c# console application
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { abstract class Apple { public void call() { // Non Abstract Method All SubClass can use without implementaion Console.WriteLine("Call Method: This method provides Calling features"); Console.WriteLine("Abstrac class called"); } // Abstract Method Sub Classes must provide implementaion for this abstract method. public abstract string GetModelName(); // Non Abstract Property public string ModelName { get; set; } // Abstract Method public abstract string IMEI { get; } } class IPhone4 : Apple { // Implementaion of Abstract Property. public override string IMEI { get { return "34234324324324"; } } // Implementaion of Abstract Method public override string GetModelName() { return "Iphone4"; } static void Main(string[] args) { IPhone4 obj = new IPhone4(); obj.call(); obj.ModelName = obj.GetModelName(); } } }