Conflicting properties from interface and abstract class

  • Thread starter Thread starter machinesofgod
  • Start date Start date
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
 
<[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
 
Back
Top