Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the C# generics naming convention come from?

I understand T comes from Type, but why is it that the next variable often used is K?

like image 911
bevacqua Avatar asked Dec 06 '10 15:12

bevacqua


1 Answers

I've seen K used for Key but not frequently as the "next" type parameter. For example, you'll see

Dictionary<K, V>

where K is for Key and V is for Value.

Sometimes you'll see T1, T2, etc. or T, U, V (the former is preferred here). But I prefer more descriptive names like

Map<TSource, TDestination>

or

Create<TUnitOfWork>
like image 182
jason Avatar answered Oct 25 '22 11:10

jason