How can I implement an interface member in protected ?
- by Nicolas Dorier
Hi,
I've been quite surprise when I saw the metadata of ReadOnlyObservableCollection in VS 2008...
public class ReadOnlyObservableCollection<T> : ReadOnlyCollection<T>, INotifyCollectionChanged, INotifyPropertyChanged
{
// Summary:
// Initializes a new instance of the System.Collections.ObjectModel.ReadOnlyObservableCollection<T>
// class that serves as a wrapper for the specified System.Collections.ObjectModel.ObservableCollection<T>.
//
// Parameters:
// list:
// The collection to wrap.
public ReadOnlyObservableCollection(ObservableCollection<T> list);
// Summary:
// Occurs when an item is added or removed.
protected virtual event NotifyCollectionChangedEventHandler CollectionChanged;
//
// Summary:
// Occurs when a property value changes.
protected virtual event PropertyChangedEventHandler PropertyChanged;
// Summary:
// Raises the System.Collections.ObjectModel.ReadOnlyObservableCollection<T>.CollectionChanged
// event.
//
// Parameters:
// args:
// The event data.
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args);
//
// Summary:
// Raises the System.Collections.ObjectModel.ReadOnlyObservableCollection<T>.PropertyChanged
// event.
//
// Parameters:
// args:
// The event data.
protected virtual void OnPropertyChanged(PropertyChangedEventArgs args);
}
As you can see, CollectionChanged, a member of INotifyCollectionChanged is implemented in protected... and I can't do that in my own class.
.NET framework should not compile !
Does someone has an explanation of this mystery ?