Blog
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    APIs
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
 

Home >> C# >> Abstraction in c# with example
Abstraction in c# with example

In object-oriented software, complexity is managed by using abstraction. Abstraction is a process that involves identifying the critical behavior of an object and eliminating irrelevant and complex denials. Abstraction is a process of identifying the relevant qualities and behaviors an object should
Views: 5060     Comments: 0
by AVADHESH PATEL on 7/5/2012

Abstraction in c# with example

In object-oriented software, complexity is managed by using abstraction. Abstraction is a process that involves identifying the critical behavior of an object and eliminating irrelevant and complex denials. Abstraction is a process of identifying the relevant qualities and behaviors an object should possess.

Example- A Laptop consists of many things such as processor, motherboard, RAM, keyboard, LCD screen, wireless antenna, web camera, USB ports, battery, speakers etc. To use it, you don't need to know how internally LCD screens, keyboard, web camera, battery, wireless antenna, speaker’s works.  You just need to know how to operate the laptop by switching it on.

Note- When derived class inherited with abstract class; derived class must be override abstract class methods.

Example of Abstraction:

using System;

using System.Collections.Generic;

using System.Linq;

namespace abstarction

{

    public abstract class university

    {

        public abstract void BTech();

        public abstract void MBA();

    }

    public class GBTU : university

    {

        public override void BTech()

        {

            Console.WriteLine("GBTU BTech Fee 50000/-");

        }

        public override void MBA()

        {

            Console.WriteLine("GBTU MBA Fee 100000/-");

        }

    }

    public class MTU : university

    {

        public override void BTech()

        {

            Console.WriteLine("MTU BTech Fee 40000/-");

        }

      public override void MBA()

        {

            Console.WriteLine("MTU MBA Fee 800000/-");

        }

    }

    class Program

    {

        static void Main(string[] args)

        {

            GBTU g = new GBTU();

            g.BTech();

            g.MBA();

            MTU m = new MTU();

            m.BTech();

            m.MBA();

            Console.ReadLine();

        }

    }

}

Output-

GBTU BTech Fee 50000/-

GBTU MBA Fee 100000/-

MTU BTech Fee 40000/-

MTU MBA Fee 800000/-

Explanation :-

Ø  From above example we have make one abstract class university and two abstract methods Btech and MBA. GBTU and MTU both are override university course fee.

Ø  University course common for both GBTU and MTU so university method BTech and MBA is abstract.

Ø  GBTU and MTU inherited abstract method so university method must be override here.

Title :  
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
       
 
Report Abuse Form
Reason:    
 
Latest ArticleRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest Blogs by AVADHESH PATELRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 2710
  
Copyright © 2009 - 2013MindStick. All Rights Reserved.