思考下面的Code,有一Test类,实现了接口ITest:
public interface ITest{ void Say(); void Run();}public class Test : ITest{ void ITest.Say() { Console.WriteLine("ITest.Say"); } void ITest.Run() { Console.WriteLine("ITest.Run"); } public void Say() { Console.WriteLine("Test Say"); } public void Run() { Console.WriteLine("Test Run"); }}class Program{ static void Main(string[] args) { ITest itest = new Test(); itest.Say(); itest.Run(); Console.WriteLine("================"); Test t = new Test(); t.Say(); t.Run(); Console.Read(); }}
这段Code正确吗?如果正确会得到的结果是?
答案:
ITest.Say
ITest.Run
================
Test Say
Test Run