|
-
Mar 18th, 2007, 06:13 PM
#1
Thread Starter
Fanatic Member
Shared members and interfaces
I'm trying to figure out a way to use an interface or maybe a MustInherit class to make sure a derived class has a specific shared member. Interfaces only enforce instance members. MustInherit classes support shared members but without the Overrideable keyword.
Any ideas on how to make sure a derived class has a specific shared member? I'd rather not have the member be an instance member, but I will if this can't be done.
-
Mar 18th, 2007, 06:55 PM
#2
Re: Shared members and interfaces
The point of inheritance and overriding members is polymorphism and polymorphism only applies to instances. You don't call Shared members on instances so overriding Shared members serves no purpose.
For example, you should be able to create an OleDbConnection instance and an SqlConnection instance and pass them both to a method that expects a DbConnection object and call their Open and Close methods. That's the whole point. You don't call Shared members on instances of any class so what's the point of ensuring that a class has the same member as its base when there is no instance to cast as any type?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|