Книги автора: C# 2008 Programmer
Книга: C# 2008 Programmer
Advantages of Generics
Advantages of Generics
It's not difficult to see the advantages of using generics:
? Type safety — Generic types enforce type compliance at compile time, not at runtime (as in the case of using Object
). This reduces the chances of data-type conflict during runtime.
? Performance — The data types to be used in a generic class are determined at compile time, so there's no need to perform type casting during runtime, which is a computationally costly process.
? Code reuse — Because you need to write the class only once and then customize it for use with the various data types, there is a substantial amount of code reuse.
Похожие страницы