How is it possible for the System.ServiceModel.ClientBase abstract class to implement IDisposable Interface if the Dispose() Method declaration is not visible/declared?
As pretty much everyone has pointed out, the interface method is explicitly implemented. The source code you are seeing for ClientBase
is from Metadata
(see Metadata as Source in Visual Studio). Note the lack of implementation for any function or a partial
keyword.
Visual Studio will not show explicitly implemented interface members from Metadata
(see Stack Overflow question 72686320)
Edit:
An explicitly implemented interface method must be called from the interface directly (this is how it differs from one that was implemented implicitly). The correct way to call it is as follows
using System;
abstract class ATest : IDisposable
{
void IDisposable.Dispose()
{
throw new NotImplementedException();
}
}
class Test : ATest
{
}
class OtherClass
{
public static void Main()
{
Test t = new Test();
((IDisposable)t).Dispose();
}
}
The result is Unhandled Exception: System.NotImplementedException: The requested feature is not implemented.