Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            {
                MovableObject obj = new MovableObject();

                // left
                ILeft objLeft = obj;
                objLeft.Move();

                // right
                IRight objRight = obj;
                objRight.Move();
            }

            Console.WriteLine("-------------");
            {
                // implementing both
                IMoving moving = new MovingObject();
                //moving.Move(); // does not compile, ambiguous call

                // left
                ILeft movingLeft = moving;
                movingLeft.Move();

                // right
                IRight movingRight = moving;
                movingRight.Move();
            }
            Console.ReadKey();
        }