alendonald — 2013-07-25T02:54:50-04:00 — #1
Tell me the difference between abstract class and interface?
cpradio — 2013-07-25T05:43:49-04:00 — #2
An interface describes a contract for a class to follow, it must implement the methods verbatim described within the interface, and abstract class does not require that.
An abstract class is an actual class (unlike an interface, which isn't a real class), it can't be instantiated, so the only way you can use an abstract class is by inheriting it. You will typically inherit it because the class you are creating is a type of the abstract class. Thus giving your new class a baseline of functionality.
system — 2013-10-15T02:22:12-04:00 — #3
Abstract class is a class that contain complete and abstract both type of member and it can not be instantiated, Abstract classes are one of the essential behaviors provided by dot net. That leaves one or more method implementations unspecified by declaring one or more methods abstract.
Interface is a type which contains only the signatures of methods, delegates or events, it has no implementation, Implementation of the methods is done by the class that which implements the interface. If there are data fields defined in an interface, then they are implicitly defined to be:
• static, and
endermb — 2013-10-29T12:24:56-04:00 — #4
Interfaces and abstract methods have been described across the Internet millions of times already. I doubt you'll get a better explanation on here than you will anywhere else on the web.
That being said, if you are coming from a Java background your idea of interfaces may differ, especially when it comes to explicit interface implementation, which to my knowledge you cannot do in Java.
If you have a complex set of business rules, it might also be worth looking at covariance, invariance, and contravariance. Again, it's been done to death elsewhere on the web, so use Google to find the explanation that works well for you, and then try building on these principles.