Monday 15 June 2015

Abstraction in OOPS C#

Abstraction: Abstraction is to hiding the complexity of object and showing the essential features of that object. It focus on what object can do instead of how it can do.
"Abstraction is to hiding the working style of an object and showing the information of an object as understandable manner"

Real world example of Abstraction:

Suppose we take example of Mobile phones.

Nokia 2710 (Features: Calling, SMS)
Nokia 3110 (Features: Calling, SMS, FM Radio, MP3, Camera)


Abstract information(All mobile phones makes a call to any number and can send SMS)

for that you have to make a abstract class:

abstract class MobilePhone
    {
        public void Calling();
        public void SendSMS();
    }

public class Nokia2710 : MobilePhone
    {
        public void FMRadio();
        public void MP3();
        public void Camera();
    }

    public class Nokia3110 : MobilePhone
    {
        public void FMRadio();
        public void MP3();
        public void Camera();
        public void Recording();
        public void ReadAndSendEmails();
    }

No comments:

Post a Comment