?
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");
}
}
时间: 2024-11-05 23:23:06