C#
  Home arrow C# arrow Page 5 - C# Simplified, part 4: Structures, Inherit...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

C# Simplified, part 4: Structures, Inheritance and Interfaces
By: Anand Narayanaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 18
    2005-05-24

    Table of Contents:
  • C# Simplified, part 4: Structures, Inheritance and Interfaces
  • Properties
  • Inheritance
  • Sealed classes
  • Abstract classes
  • Interfaces
  • Combining Interfaces

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    C# Simplified, part 4: Structures, Inheritance and Interfaces - Abstract classes


    (Page 5 of 7 )

    The abstract class is a special type of class which contains one or more abstract methods. It should be declared with the keyword abstract. Every abstract class consists of one or more abstract methods. These methods will only have the method definitions. The abstract class will not have any method body, such as the instance method or the class method.

    Basically, a base class is declared with the abstract keyword, and the derived classes should inherit the abstract class and provide implementation for the relevant methods. In listing 4.5, an abstract method named Display() is declared inside the AbstractDemo class. The derived class then inherits the abstract class and provides implementation to the abstract method. Inside the Main() method, an instance of the class is created and the method is called.

    Listing 4.5

    using System;

    abstract public class AbstractDemo

    {

    public abstract void Display();

    }

    class AbstractImp:AbstractDemo

    {

    public override void Display()

    {

    Console.WriteLine("Abstract Method Implemented");

    }

    public static void Main()

    {

    AbstractImp abs = new AbstractImp();

    abs.Display();

    }

    }

    More C# Articles
    More By Anand Narayanaswamy


     

    C# ARTICLES

    - Coding a CRC-Generating Algorithm in C
    - Cyclic Redundancy Check
    - Handling Methods and Functions
    - Destroying Objects in C#
    - Creating Objects in C-Sharp
    - Classes and Objects
    - Programming Languages: Managed versus Native
    - LINQ-to-MySQL with DbLinq in C#
    - Working with Dates and Times in C#
    - Generics, Dictionaries, and More
    - More About Generics
    - Working with C# Collections
    - Generics
    - C# and XML
    - Pointers and Arrays in C#





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek