Sunday, March 22, 2015
Generics
Generics
Generics is one of the most powerful feature provided in .Net 2.0. It allows us to create a type safe data structures, without actually committing to a single data type. It is similar to C++ templates.
Generics allows user to delay the specification of data types. We can create a class or method and actual data type is not specified until it is used. Thus it can work with any data type.
We write specification for the class or method, with a substitute parameter for data type. When compiler encounters this class/method/constructor , it generates code to handle specific data type.
Benefits :
Significance performance boost
Quality code
Re-use without type cast
Generics is one of the most powerful feature provided in .Net 2.0. It allows us to create a type safe data structures, without actually committing to a single data type. It is similar to C++ templates.
Generics allows user to delay the specification of data types. We can create a class or method and actual data type is not specified until it is used. Thus it can work with any data type.
We write specification for the class or method, with a substitute parameter for data type. When compiler encounters this class/method/constructor , it generates code to handle specific data type.
Benefits :
Significance performance boost
Quality code
Re-use without type cast
Subscribe to:
Comments (Atom)