-
4
pages
-
English
-
Documents
Description
B E G I N N E R S C # T U T O R I A LL E S S O N 9 - P O LY M O R P H I S M BEGINNERS’S C # T U T O R I A L9 . P O L Y M O R P H I S MW R I T T E N B Y J O E M A Y OJ M A Y O @ C S H A R P – S T A T I O N . C O MU P D A T E D 1 5 / 0 1 / 0 1 , 1 2 / 0 3 / 0 3C O N V E R T E D T O P D F B Y A S H W E A V E R 0 2 / 0 9 / 0 3W W W . C S H A R P – S T A T I O N . C O M P A G E 1 O F 4C O P Y R I G H T © 2 0 0 0 – 2 0 0 3 C # S T A T I O N , A L L R I G H T S R E S E R V E DB E G I N N E R S C # T U T O R I A LL E S S O N 9 - P O LY M O R P H I S M This lesson teaches about Polymorphism in C#. Our objectives are as follows: Learn What Polymorphism Is. Implement a Virtual Method. Override a Virtual Method. Use Polymorphism in a Program. Another primary concept of object-oriented programming is Polymorphism. It allows you to implement derived class methods through a base class pointer during run-time. This is handy when you need to assign a group of objects to an array and then invoke each of their methods. They won't necessarily have to be the same object type. However, if they're related by inheritance, you can add them to the array as the inherited type. Then if they all share the same method name, that method of each object can be invoked. This lesson will show you how to accomplish this. Listing 9-1. A Base Class With a Virtual Method: DrawingObject.cs using System; public class DrawingObject {public virtual void ...
-
Publié par
-
Langue
English