本文介绍了基本关键字 - 帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个实现接口的基类(空中代码): class BaseClass:SomeInterface { void SomeInterface.ImplMethod() { // - 此处代码 - } } 类派生:SomeInterface { void SomeInterface.ImplMethod() { //需要在此处调用基础实现 // - 此处代码 - } } 如果不公开实现,有办法吗? TIA Krishnan Hi,Am having a base class that implements an interface (air code) : class BaseClass : SomeInterface{void SomeInterface.ImplMethod(){// -- code here --}} class Derived : SomeInterface{void SomeInterface.ImplMethod(){//NEED TO CALL BASE''S IMPLEMENTATION HERE// -- code here --}} Without making the implementations public, is there a way to do it? TIAKrishnan推荐答案 派生类不会从基类继承吗? 但是,即使继承,我也找不到一种方法来调用基础 类接口函数。也许其他人知道怎么做? 我只是通过将代码移动到辅助函数来找到解决办法。 像这样: 界面SomeInterface { void ImplMethod(); } 类BaseClass:SomeInterface { protected void方法(){/ *代码在这里* /} void SomeInterface.ImplMethod(){Method()} } class派生:BaseClass,SomeInterface { void SomeInterface.ImplMethod(){base.Method(); } } 问候, Wessel The derived class doesn''t inherit from the base class? However, even when inheriting, I couldn''t find a way to call the baseclass interface function. Maybe someone else knows how to do it? I only found this work-around, by moving the code to a helper function.Like this: interface SomeInterface{void ImplMethod();} class BaseClass : SomeInterface{protected void Method() { /* Code goes here */ }void SomeInterface.ImplMethod() { Method() }} class Derived : BaseClass, SomeInterface{void SomeInterface.ImplMethod() { base.Method(); }} Greetings,Wessel 这篇关于基本关键字 - 帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-14 09:01