界面采访问题 [英] interface interview question
本文介绍了界面采访问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
一个界面如何从多个界面继承自己?
请帮我解释如何实现如何调用方法?(采取如下所示)
示例:
hi
how does one interface inherited itself from more than one interface?
please help me how to implement that how to call methods?(take a look below)
EXAMPLE:
public interface IFirst { void oneMethod(); }
public interface ISecond { void oneMethod(); }
public class:IFirst,ISecond
{
// I want implement those methods here.how is it?
}
推荐答案
显式接口实现
更多信息
public interface IFirst { void oneMethod(); }
public interface ISecond { void oneMethod(); }
public class:IFirst,ISecond
{
// I want implement those methods here.how is it?
}
--answer
--answer
public class myclass:IFirst,ISecond
{
// I want implement those methods here.how is it?
public void IFirst.oneMethod
{
//do something
}
public void ISecond.oneMethod
{
// do something
}
//call the method like this
IFirst obj=new myclass();
ISecond obj1=new myclass();
obj.oneMethod();
obj1.oneMethod();
}
这篇关于界面采访问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文