Example #1
0
        public static void infDemoTest()
        {
            Console.WriteLine("Hello Interfaces");
            infDemo inf = new infDemo();

            inf.pqr();
            Console.WriteLine("new class infDemo");
            abc infa = (abc)inf; //interface

            infa.xyz();
            Console.WriteLine("interface abc");
            Sample s = new Sample();

            s.xyz();
            Console.WriteLine("new class Sample");
            abc infb = (abc)s;

            infb.xyz();
            Console.WriteLine("interface abc");

            abc infc = new infDemo(); //new keywork interface

            infc.xyz();


            abc[] infArray = { new infDemo(), new Sample() };
            for (int i = 0; i < infArray.Length; i++)
            {
                infArray[i].xyz();
            }
        }
Example #2
0
    public static void Main()
    {
        System.Console.WriteLine("Hello Interfaces");
        InterfaceDemo8 refDemo = new InterfaceDemo8();
        abc            refabc  = refDemo;

        refabc.xyz();
        def refdef = refDemo;

        refdef.pqr();
//      refdef.xyz();  /* try uncommenting line */
    }