ClientBase doesn't implement IDisposable member

前端 未结 3 1305
旧巷少年郎
旧巷少年郎 2021-02-20 14:08

How is it possible for the System.ServiceModel.ClientBase abstract class to implement IDisposable Interface if the Dispose() Method declaration is not visible/declared?

3条回答
  •  耶瑟儿~
    2021-02-20 14:25

    using explicit interface implementation.

    IDisposable is visible and can be invoked as

    var client = new WCFTestServiceClient(); // assumingWCFTestServiceClient is WCF client proxy that inherits from ClientBase
    (client as IDisposable).Dispose();
    

提交回复
热议问题