object
reference can hold a reference to any other
type of data, it is possible to use an
object
reference to refer to any type of data. Thus, an array
of
object
as used by the program can store any type of data. Expanding on this concept, it is
easy to see how you could construct a stack class, for example, that stored
object
references.
This would enable the stack to store any type of data.
Although the universal-type feature of
object
is powerful and can be used quite effectively
in some situations, it is a mistake to think that you should use
object
as a way around C#’s
otherwise strong type checking. In general, when you need to store an
Do'stlaringiz bilan baham: |