hultqvist
hultqvist

Reputation: 18471

Implementing multiple properties in different namespaces

I tried to implement IEnumerator< Status > but got errors about two different Properties not being implemented.

'DataReader' does not implement interface member 'System.Collections.Generic.IEnumerator.Current'

'DataReader' does not implement interface member 'System.Collections.IEnumerator.Current'

The solution that worked was:

    public Status Current { get; set; }

    object System.Collections.IEnumerator.Current
    {
        get { throw new NotImplementedException(); }
    }

It looks like I could have multiple Properties with the same name separated by different namespaces.

What is this type of "property overloading" called? And how can I find out more about it.

Upvotes: 2

Views: 183

Answers (1)

Fredrik M&#246;rk
Fredrik M&#246;rk

Reputation: 158349

The second property implementation is an explicit interface implementation. It specifically implements the property Current for the IEnumerable interface. The reason you need to do this is that the Current property of your class is not the same type (Status vs object), so it doesn't match what the interface dictates.

Upvotes: 4

Related Questions