static void Main(string[] args)
        {
			MyClass mc = new MyClass(); // Create instance
			mc.PrintOut("jack_kate");	// Call method

			IIfc1 ifc = (IIfc1)mc; // cast the reference to the class obj to the interface type.
			ifc.PrintOut("hello"); // use reference to interface to call member.
		}
示例#2
0
        static void Main(string[] args)
        {
			MyClass mc = new MyClass();	// Create class object.
			mc.PrintOut("Object");		// Call class object implementation method.

			IIfc1 ifc = (IIfc1)mc;		// Cast class object ref to interface ref.
			ifc.PrintOut("Interface");	// Call interface method.
		}
示例#3
0
        static void Main()
        {
            MyClass my = new MyClass();

            my.Method();

            //Delay.
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
			MyClass mc = new MyClass();			// Create class object.

			IIfc1 ifc1 = (IIfc1)mc;				// Get ref to IIfc1
			IIfc2 ifc2 = mc as IIfc2;			// Get ref to IIfc2

			ifc1.PrintOut("interface1");		// Call explicit implementation
			ifc2.PrintOut("interface2");		// Call explicit implementation
		}
        static void Main(string[] args)
        {
			MyClass mc = new MyClass();
			mc.PrintOut("object");
		}