Programming Hub C,C++,C#,Asp.Net,Ado.Net,Java,  HTML,SQL.

This Blog Post Only Education Purpose For All Education Related Blogs and Articles Post Here.Download Free Software and Study Materials Mores..

Saturday, 19 July 2014

Abstract Class in C#? example

                 Abstract Class in C#?


“An abstract is implement that the class is incomplete and can’t be use directly, to use an abstract class other class can derived.”

“An abstract class contains abstract method which can be implemented by the…

v You can’t create instance of a abstract class.
v You can’t override the method of the abstract class in the base class.
v You can’t declare abstract method outside abstract class.
v You can’t declare abstract class as a sealed.
v A class which is derived from the abstract class must override all the method inside the abstract class.
v If a derived class doesn’t implement all of the abstract method in the base class, then the derived class must also be specified by abstract.
v Abstract method is method without any body.
Example:
using System;

abstract class Animal
{
    public abstract void FoodHabits();
}
class Carnivorous:Animal
{
    public override void FoodHabits()
{
    Console.WriteLine("The Carnivorous Animal Eat Only Meat");
}
}
class Herbivorous:Animal
{
    public override void FoodHabits()
    {
        Console.WriteLine("The Harbivorous Animal Eat Only Plants");
    }
}
class Implement
{
    public static void Main()
    {
        Carnivorous cn = new Carnivorous();
        Herbivorous hb = new Herbivorous();
        cn.FoodHabits();
        hb.FoodHabits();
        Console.ReadLine();
    }
}


See the output below…..

SO Friends these are few Blogs that will help you in "Abstract Class in C-sharp" next time i will put some more interesting Blogs thank you..I Hope Helpfull u.. enjoy :).
Krishna Singh

2 comments:

Please Comment Your Valuable Feedback....

You Might Also Like

Developing Data-Centric Windows Applications using Java

Developing Data-Centric Windows Applications using Java Introduction The Core Java Programming and JDBC course provides an introd...

Unlimited Reseller Hosting