Example #1
0
        static void Main(string[] args)
        {
            MovableObject obj = new MovableObject();

            // left
            ILeft objLeft = obj;

            objLeft.Move();

            // right
            IRight objRight = obj;

            objRight.Move();

            // implementing both
            IMoving moving = new MovingObject();
            // smoving.Move(); // does not compile, ambiguous call

            // left
            ILeft movingLeft = moving;

            movingLeft.Move();

            // right
            IRight movingRight = moving;

            movingRight.Move();
        }
Example #2
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();
        }
Example #3
0
        static void Main(string[] args)
        {
            var moveableObj = new MoveableOject();
            //moveableObj.Move();
            ILeft left = moveableObj;

            left.Move();

            ((ILeft)moveableObj).Move();
            ((IRight)moveableObj).Move();
        }
Example #4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ILeft != 0)
            {
                hash ^= ILeft.GetHashCode();
            }
            if (IRight != 0)
            {
                hash ^= IRight.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }