About Interface

 

http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners

 

Interface can't have things like int x;

All interface defined function must be realized with public decorator.

 

Here is an example for object array

class Demo : abc

{

public static void Main()

{

abc [] refabc = {new Demo(), new Sample()} ;

for (int i = 0; i<= 1; i++)

refabc[i].xyz();

}

 

public void xyz()

{

System.Console.WriteLine("In Demo :: xyz");

}

}

 

interface abc

{

void xyz();

}

 

class Sample : abc

{

public void xyz()

{

System.Console.WriteLine("In Sample :: xyz");

}

}

上一篇:腾讯 or 华为 =》 求职者的困惑


下一篇:[转载] PHP开发必看 编程十大好习惯