implementing abstract methods inside an abstract class

Posted by Gayathri under C# on 10/8/2010 | Points: 10 | Views : 2126 | Status : [Member] | Replies : 2
Hi,
IF i am not wrong , it is not compulsory that the abstract methods inside an abstract class must be implemented in the derviedclass.
whereas it is a must in the case of interfaces.

using System;

abstract class abssample
{
public abstract void ABM();
// public abstract void disp(); -- >displays an error if i donot implement this in the dervied class.
public void DisplayMsg()
{
Console.WriteLine(" I am a non Abstract Method inside an abstract class");
}
public virtual void ViM()
{
Console.WriteLine("Virtual Method inside the asbtract class");
}
}

class D : abssample
{
public override void ABM()
{
Console.WriteLine("Abstract Method of an abstract class - abssample");
}
public override void ViM()
{
Console.WriteLine("Virtual Method of an abstract class");
}
}

class test
{
static void Main()
{
D dobj = new D();
dobj.ABM();
dobj.DisplayMsg();
dobj.ViM();
}
}




Responses

Posted by: Prasham on: 10/8/2010 [Member] Starter | Points: 25

Up
0
Down
Hello,

Derived classes of the abstract class must implement all abstract methods.

Please go through following links those will help you
http://msdn.microsoft.com/en-us/library/ms173150(VS.80).aspx
http://radio-weblogs.com/0111551/stories/2002/10/11/cAbstractClasses.html
http://www.blackwasp.co.uk/AbstractClasses.aspx

Thanks
Prasham

Thanks and Best Regards
Prasham

Gayathri, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 10/14/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Gayathri,

http://www.pragimtech.com/Abstract.aspx

Refer this link i hope you get more idea about Abstract Class.

Cheers :)

Thanks,
T.Saravanan

Gayathri, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response