namespace ConsoleApplication10Inter
{
interface Interd1
{
void draw();
}
interface Interd2
{
void draw();
}
class Class2 : Interd1,Interd2
{
void Interd1.draw()
{
Console.WriteLine("draw in interface1");
}
void Interd2.draw()
{
Console.WriteLine("draw in interface2");
}
}
class Program
{
static void Main(string[] args)
{
Class2 T = new Class2();
Interd1 d1 = (Interd1)T;
d1.draw();
Interd2 d2 = (Interd2)T;
d2.draw();
}
}
}<6>
接口类似于抽象基类:实现接口的任何非抽象类型都必须实现接口的所有成员。
不能直接实例化接口。
接口可以包含事件、索引器、方法和属性。
接口不包含方法的实现。
类和结构可继承多个接口。
接口自身可从多个接口继承。
原文:http://blog.csdn.net/ddupd/article/details/21884407