.NET2.0 Base Class Library 系列(四)泛型 Generics Type
- introduction to Generics
Generic classes and methods combine reusability, type safety and efficiency in a way that their non-generic counterparts cannot. Generics are most commonly used with collections and the methods that operate on them. Because no casting needed,no boxing needed. - Benefits of Generics
By creating a generic class, you can create a collection that is type-safe at compile-time.
1Use generic types to maximize code reuse, type safety, and performance.
using System.Collections.Generic;
2
3
public List<int> myList = new List<int>();
4
- http://msdn2.microsoft.com/en-us/library/512aeb7t(vs.80).aspx

浙公网安备 33010602011771号