Beispiel #1
0
        static void Main(string[] args)
        {
            KDerived d = new KDerived();

            d.Start();
            d.Update();
            KBase b = new KDerived();

            b.Start();
            b.Update();
            KBase c = new KFinal();

            c.Start();
            c.Update();
            Console.ReadKey();

            /*
             *  KDerived::Start
             *  KBase::Update
             *  KDerived::Update
             *  KBase::Start
             *  KBase::Update
             *  KDerived::Update
             */
        }
        static void Main(string[] args)
        {
            KBase b = new KDerived();

            b.DoUpdate();
            Console.ReadKey();

            /*
             *  KDerived::Update
             *  KDerived::LateUpdate
             */
        }
        static void Main(string[] args)
        {
            KBase b = new KDerived();

            b.Start();
            b.Update();
            Console.ReadKey();

            /*
             *  KDerived::Start
             *  KDerived::Update
             */
        }
        static void Main(string[] args)
        {
            //KBase b = new KBase();
            //KDerived d = (KDerived)b;
            //Console.WriteLine("{0}", d._fData); // exception

            KDerived d2 = new KDerived();
            KBase    b2 = d2;

            Console.WriteLine("{0}", b2._iData);
            KDerived d3 = (KDerived)b2;

            Console.WriteLine("{0}", d3._fData);
        }
Beispiel #5
0
    static void Main()
    {
        dynamic o1 = new KDerived();
        KBase   o2 = new KDerived();

        o1.Start();  // calls Start() of actual type
        o2.Start();  // calls Start() of variable type

        o1.Update(); // Update() is virtual function, so there is no difference with below
        o2.Update();

        /*  output:
         *  KDerived::Start
         *  KBase::Start
         *  KDerived::Update
         *  KDerived::Update
         */
    }
        static void Main(string[] args)
        {
            //KBase b = new KBase();
            //KDerived d = (KDerived)b;
            //Console.WriteLine("{0}", d._fData); // exception

            KDerived d2 = new KDerived();
            KBase    b2 = d2;

            Console.WriteLine("{0}", b2._iData);
            KDerived d3 = (KDerived)b2;

            Console.WriteLine("{0}", d3._fData);

            GetDataDelegate <string> s0 = () => { return("Hello"); };
            GetDataDelegate <object> s1 = s0;

            string str0 = s0();

            Console.WriteLine("{0}", str0);
            string str1 = (string)s1();

            Console.WriteLine("{0}", str1);
        }