문제

Why isn't HashAlgorithm.Dispose public?

void IDisposable.Dispose()
{
    this.Dispose(true);
    GC.SuppressFinalize(this);
}

I understand that it is an explicit interface implementation and can still be called. I am trying to work out the reasoning behind it.

도움이 되었습니까?

해결책

This is called explicit interface implementation. The only way to call this method is to cast to a IDisposable object. One good example of when this might be useful is when you have a class which implements two interfaces that both have the same method name and you want to provide a different implementation for each of them.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top