what is the difference between abstract and interface? where should we implements all methods?

Posted by Rajendra.prasad under C# on 5/10/2011 | Points: 10 | Views : 1050 | Status : [Member] | Replies : 4
Hi,

what is the difference between abstract and interface? where should we implements all methods?
like if we inherit an abstract class, should we implement all the methods or else if we implement an interface shall we implements all the methods declared in an interface. little bit confused. please help me. can any one can give me clear idea/information regarding this?

Regards,
Rajendra




Responses

Posted by: Lokesh76 on: 5/11/2011 [Member] Starter | Points: 25

Up
0
Down
visit below article

http://www.codeproject.com/KB/architecture/Abstract_Interface.aspx

Thanks
Lokesh Kumar

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

Posted by: Rajendra.prasad on: 5/11/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Lokesh,
thanks for your quick and valuable info.

Regards,
Rajendra

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

Posted by: Lakn2 on: 5/12/2011 [Member] Starter | Points: 25

Up
0
Down
The main prurpost of Abstract class and Interface is to define common methods.And the difference between abstracr class and Interface is If we define some methods in abstract class in derived class we may or may not implement those methods but in case of interface we should implement all methods.And we can give access modifiers in abstract class but in interface by default those are public so we don't have any permission to change or to give that access modifer.

Thanks&Regards
LakshmiNarayana Nalluri.

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

Posted by: Nishithraj on: 5/12/2011 [Member] Bronze | Points: 25

Up
0
Down
I agree with the defnition given by LakshmiNarayana. Would like to add one more thing.

Abstract class comes under inheritance(Equivalent keyword for this in VB.NET is MustInherit).
But interface is not.

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

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

Login to post response