Objects with Different Behaviors

Sometimes it's appropriate to classify each object in a group as belonging to the same group, but still allow each object to maintain its own behavior. When speaking of each object, it would be useful to group them into the same category; yet it is also practical for each object to have its own identity as required—same but different.

For instance, a pigeon, a robin, and a seagull are objects relating to the bird group. A biologist wants to conduct a behavioral experiment with these three birds. So one day the biologist grabs the birds and puts them in a specially built birdcage where each bird has its own compartment. The cage may be similar to a pigeon coop, but it can't be a pigeon coop because another bird ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.