コード例 #1
0
        /// <summary>
        /// Demonstrates inheritance
        /// </summary>
        /// <param name="args">command-line arguments</param>
        static void Main(string[] args)
        {
            // Problem 1
            // parent class message
            Kid kid = new Kid();

            kid.PrintMessage();


            // Problem 2
            // a child class message
            DisobedientKid disobedientKid = new DisobedientKid();

            disobedientKid.PrintMessage();
            ArtisticKid artisticKid = new ArtisticKid();

            artisticKid.PrintMessage();

            // another child class message
            SharingKid sharingKid = new SharingKid();

            sharingKid.PrintMessage();

            Console.WriteLine();
        }
コード例 #2
0
        static void Main()
        {
            Kid kid         = new Kid();
            Kid friendlyKid = new FriendlyKid();
            Kid artisticKid = new ArtisticKid();

            kid.PrintMessage();
            friendlyKid.PrintMessage();
            artisticKid.PrintMessage();

            Console.ReadLine();
        }