Monday 13 April 2015

Pure Abstract class in C# dot net

Hello Friends,
Now I am going to describe anther concept i.e.Pure abstract class.It is a extended version of abstract class.which contains only abstract methods but we can't declare a body inside this abstract method.
But the disadvantages of pure abstract class is that this class can't inhert multiple time means that multiple pure abstract class is not possible.So To overcome this problems interface concept is introduced.

Ex:

using System;

namespace pureabstractclass
{
abstract class pureabstract
{
public abstract void mypureabs ();
public abstract void mypureabs1 (int s,int p);
}
 class pureabs:pureabstract
{
public override void mypureabs ()
{
Console.WriteLine ("hello.........");
}
public override void mypureabs1 (int s,int p)
{
Console.WriteLine (s*p);
}
}
class MainClass
{
public static void Main (string[] args)
{
pureabs obj = new pureabs ();
obj.mypureabs ();
obj.mypureabs1 (30,40);
}
}
}


Output:
hello.........
1200

No comments:

Post a Comment