コード例 #1
0
        public static void Main(string[] args)
        {
            System.Console.WriteLine("Hello Interfaces");
            //xyz();//An object reference is required for the non-static field, method, or property 'Program.xyz()'
            Program obj = new Program();//obj is a reference to the object of class Program.

            obj.xyz();
            Sample SampleObj = new Sample();//SampleObj is a reference to the object of class Sample.

            SampleObj.xyz();
            abc interface_obj = new Program();

            interface_obj.xyz();
            abc Sample_interface_obj = new Sample();

            Sample_interface_obj.xyz();
            abc[] refabc = { new Program(), new Sample() };
            for (int i = 0; i <= 1; i++)
            {
                refabc[i].xyz();
            }
            def refdef = obj;

            refdef.pqr();
            refdef.xyz();
            man inheriobj = obj;

            inheriobj.xyz();
            inheriobj.pqr();
            Console.ReadLine();
        }
コード例 #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 */
    }