class Program { static void Main(string[] args) { //调用显示接口 Test t = new Test(); //调用了test1.run方法 ((ITest1)t).Run(); //调用了test2.run方法 ((ITest2)t).Run(); Console.Read(); } }
public interface ITest1 { void Run(); } public interface ITest2 { void Run(); } public class Test : ITest1, ITest2 { void ITest1.Run() { Console.WriteLine("实现了Test1的RUN方法"); } void ITest2.Run() { Console.WriteLine("实现了Test2的RUN方法"); } }