Examples from Chapter 6 (Inheritance) of Programming C# 8.0 (O'Reilly).
- Example 3. Feeling downcast
- Example 4. The as operator
- Example 5. Type pattern
- Example 6. The is operator
- Example 9. Deriving from a generic base class
- Example 10. Requiring a type argument to derive from the type it's applied to
- Example 11. A method accepting any Base
- Example 12. A method accepting any IEnumerable
- Example 13. Passing an IEnumerable<T> of a derived type
- Example 14. A method accepting any ICollection<Base>
- Example 15. Error: trying to pass an ICollection<T> with a derived type
- Example 16. Covariant type parameter
- Example 17. Class hierarchy with actual members
- Example 18. Comparing shapes
- Example 19. Contravariant type parameter
- Example 20. Changing an element in an array
- Example 21. Passing an array with derived element type
- Example 22. A class with a virtual method
- Example 23. Using a virtual method
- Example 24. Overriding virtual methods
- Example 25. Exploiting virtual methods
- Example 26. An abstract class
- Example 27. Abstract interface implementation
- Example 28. Base type version 1.0
- Example 29. Class derived from version 1.0 base
- Example 30. Base type version 1.1
- Example 31. Hidden versus virtual method
- Example 32. Avoiding warnings when hiding members
- Example 33. Hiding to change the signature