public interface IA 
{ void TestA(); } 
class aa():IA
{
 public void TestA() { Console.WriteLine("Test A"); }
 public void TestB() {Console.WriteLine("Test B"); } 
}
class Program { 
static void Main(string[] args) 
{
 IA aa =new class aa(); 
aa.TestA();
aa.TestB(); //如何通过接口aa来实现这个方法呢

解决方案 »

  1.   

    public interface IA 
        { 
        void TestA(); 
        } 
    public class aa:IA
        {
         public void TestA() 
         { 
            Console.WriteLine("Test A");
         }
         public void TestB() 
         {
           Console.WriteLine("Test B");
         } 
        }
    class Program 

      static void Main(string[] args) 
      {
       aa a1 =new aa(); 
       a1.TestA();
       a1.TestB(); 
      }

      

  2.   

    public interface IA 
    { void TestA(); } 
    class aa():IA
    {
     public void TestA() { Console.WriteLine("Test A"); }
     public void TestB() {Console.WriteLine("Test B"); } 
    }
    class Program { 
    static void Main(string[] args) 
    {
     IA aa =new class aa(); 
    aa.TestA();
    aa.TestB(); //如何通过接口aa来实现这个方法呢

    ----------------------------------
    IA没有TestB方法,所以不能调用而且不能通过编译
    class aa具有TestB,所以IA aa对象可以强制转换(其实本来就是)成class aa来调用TestB。
    注意你的名称,很容易混淆
      

  3.   

    aa.TestB(); //如何通过接口aa来实现这个方法呢
    ------------
    表达貌似有些问题.
    public interface IA 
    { void TestA(); 
      void TestB();