You can name type parameters in generic classes and generic methods anything you like. But you should typically follow the following naming conventions for naming type parameters:
- Use a short descriptive name
- Use “T” as the first letter of the type parameter
- Use “T” alone as the type parameter if it is the only parameter and if a longer name would not make its use more clear
Here are a couple examples from the .NET Framework source code:
1
2
3
4
5
6
7
| class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue> { IDictionary<TKey, TValue> dictionary; public ReadOnlyDictionary(IDictionary<TKey, TValue> dictionary) : this (dictionary, true ) { |
1
| public static ReadOnlyCollection<T> AsReadOnly<T>(T[] array) { |