/*
* Created by sharpdevelop.
* User: noo
* Date: 2009-8-16
* Time: 17: 35
*
* Interface 2 (explicitly and implicitly execute interface members)
*
* Class implicitly executes interface members (interface members can be accessed through class and interface objects)
* Explicitly execute interface members (interface members can only be accessed through interface objects)
*
*/
Using system;
Interface imyinterface
{
Void output1 ();
Void output2 ();
}
Class myclass: imyinterface
{
Public void output1 () // This method indicates that the member function can be accessed through a class or interface object.
{
Console. writeline ("implicit invocation interface member ");
}
Void imyinterface. output2 () // Note: Public, private, protected, and other modifiers cannot be added before. This method indicates that only interface objects can be used for access.
{
Console. writeline ("explicitly executing interface members ");
}
}
Class Test
{
Static void main ()
{
Imyinterface A = new myclass ();
A. output1 ();
A. output2 ();
// A can execute two interface members: output1 and output2.
Myclass B = new myclass ();
B. output1 ();
// The output2 interface member cannot be executed in B.
}
}