Casting within inheritance hierarchies
Casting between types is subtly different from converting between types. Casting is between similar types, like between a 16-bit integer and a 32-bit integer, or between a superclass and one of its subclasses. Converting is between dissimilar types, such as between text and a number.
For example, if you need to work with multiple types of
stream, then instead of declaring specific types of stream like
FileStream, you could declare an array of
Stream, the supertype of
Program.cs, add a statement...