int
,
string
,
object
, or a user-defined class.
Prior to generics, you might have created several different versions of the same algorithm to
handle different types of data. Through the use of generics, you can define a solution once,
independently of any specific type of data, and then apply that solution to a wide variety of
data types without any additional effort.
This chapter describes the syntax, theory, and use of generics. It also shows how generics
provide type safety for some previously difficult cases. Once you have completed this chapter,
you will want to examine Chapter 24, which covers Collections. There you will find many
examples of generics at work in the generic collection classes.
Do'stlaringiz bilan baham: |