Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# discussion: Interfaces
Message
General information
Forum:
ASP.NET
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
01335713
Message ID:
01335831
Views:
10
From "Pro C# .NET"

"...when a class is marked abstract, in may define any number of abstract members to provide a polymorphic interface to all derived types. However, event when a class type does define a set of abstract member, it is also free to define any number of constructors, field data, nonabstract member (with implementation), and so on. Interfaces, on the other hand, only contain abstract members.

This polymorphic interface established by and abstract parent class suffers from one major limitation in that only derived types support the members defined by the abstract parent. However, in larger software systems, it is very common to develop multiple class hierarchies that have no common parent beyond System.Object. Given that abstract members in an abstract base class only apply to derived types, we have no way to configure types in different hierarchies to support the same polymorphic interface."

The author goes on for another page.

Here's an example, for a type to be used by LINQ, it must inherit from IQueryable. But, each type may be from a different hierarchy. If IQueryable wasn't an Interface, it would impossible to do things like LINQ.



>Why?
>
>So far they look like a nice academic exercise. I've had a number of clients quiz me on interfaces during interviews, and after I answer their questions I always ask them if they are actually using them.. So far, the answer is 'we plan to use them in the future'.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform