コード例 #1
0
ファイル: Program.cs プロジェクト: agraphe/C-Sharp-3.0
        public void Run()
        {
            // assign derived instance to base reference
            Telephone phone1 = new DigitalPhone();
            Telephone phone2 = new TalkingPhone();
            Telephone phone3 = new DigitalCellPhone();
            phone1.Ring(); // accessing the polymorphic method
            phone2.Ring(); // accessing the polymorphic method
            phone3.Ring(); // accessing the polymorphic method

            DigitalPhone phone4 = new DigitalPhone();
            DigitalPhone phone5 = new DigitalCellPhone();
            phone4.VoiceMail();
            phone5.VoiceMail();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: agraphe/C-Sharp-3.0
        public void Run()
        {
            // assign derived instance to base reference
            Telephone phone1 = new DigitalPhone();
            Telephone phone2 = new TalkingPhone();
            Telephone phone3 = new DigitalCellPhone();

            phone1.Ring(); // accessing the polymorphic method
            phone2.Ring(); // accessing the polymorphic method
            phone3.Ring(); // accessing the polymorphic method

            DigitalPhone phone4 = new DigitalPhone();
            DigitalPhone phone5 = new DigitalCellPhone();

            phone4.VoiceMail();
            phone5.VoiceMail();
        }