Conflicting properties from interface and abstract class

M

machinesofgod

Hi,

I have a class that implements the ICollection interface and subclasses
the PropertyDescriptor class. The problem is that both the interface
and base class are expecting an implementation of the IsReadOnly
property. I have tried qualifying the property names with the interface
and base class name but it then complains that the modifiers 'override'
and 'public' are not valid for the property.

I've had a search around and I can only find topics discussing
conflicing method names rather than properties.

has anyone had a similar problem?

Regards,
Tom
 
J

Joanna Carter [TeamB]

<[email protected]> a écrit dans le message de (e-mail address removed)...

| I have a class that implements the ICollection interface and subclasses
| the PropertyDescriptor class. The problem is that both the interface
| and base class are expecting an implementation of the IsReadOnly
| property. I have tried qualifying the property names with the interface
| and base class name but it then complains that the modifiers 'override'
| and 'public' are not valid for the property.
|
| I've had a search around and I can only find topics discussing
| conflicing method names rather than properties.

ICollection doesn't include IsReadOnly, so I can't find a problem with a
name clash there.

However, if you need to implement the same property in an interface that
does include IsreadOnly, then you should do it like this :

class MyClass : PropertyDescriptor, IInterfaceThatIncludesIsReadOnly
{
public override bool IsReadOnly // PropertyDescriptor
{
...
}

bool IInterfaceThatIncludesIsReadOnly.IsReadOnly
{
...
}
}

Joanna
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top