コード例 #1
0
    static void Main()
    {
        Customer C1 = new Customer();

        C1.Customer2Print();
        C1.Customer3Print();
        C1.Customer1Print();

        ICustomer2 IC2 = new Customer();

        IC2.Customer2Print(); // Only ICustomer2 member available.

        Program P = new Program();

        ((I1)P).InterfaceMethod(); //As the method names in both the interface us same. InterfaceMethod() cannot be called on Program object.
        ((I2)P).InterfaceMethod();

        /* OR */
        I1 i1 = new Program();
        I2 i2 = new Program();

        i1.InterfaceMethod();
        i2.InterfaceMethod();

        /* OR */
        I1 ii1 = new Program();
        I2 ii2 = (Program)ii1; //may not be a good practice in actual, but depends.

        ii1.InterfaceMethod();
        ii2.InterfaceMethod();


        Console.ReadKey();
    }