例如:
using System;
using System.Collections.Generic;
using System.Text;namespace TestMe
{
    interface myinterface
    {
        void aa();
    }
    class a : myinterface
    {
        public void aa()
        {
            Console.WriteLine("aa");
        }
        public void aaa()
        {
            Console.WriteLine("aaa");
        }
    }    class Program
    {
        static void Main(string[] args)
        {
            myinterface b;
            b = new a();
            b.aa();
            /*
            如果我要用aa这个方法的话用
            a test2 = new a(); test2.aa(); 这样也行啊,接口有什么好处啊?什么时候该用接口?
            */
            Console.ReadKey();
        }
    }
}

解决方案 »

  1.   

    和JAVA里面应该是一样的吧   支持多继承.....
      

  2.   

    那为什么还要接口呢?自己实现自己的不就完了吗?------------------------------------------------------
    比如:电视类和马桶类都实现了这个接口,这样就可以使用一个操作,打开所有的电视机和马桶,单独实现功能也是可以的,但是会比较零乱。interface ObjCanOpen
    {
        void Open();
    }class TV : ObjCanOpen
    {...}class Closestool : ObjCanOpen
    {...}void OpenAll
    {
        ArrayList al = new ArrayList();
        al.Add(new TV());
        al.Add(new Closestool());
        foreach(ObjCanOpen o in al)
        {
            o.Open()
        }
    }
    接口在设计模式中应用很多,比如模板方法……