I understand T
comes from Type
, but why is it that the next variable often used is K
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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>
回答2:
My guess would be that it's from Key
.
回答3:
One more variation is the GenericFunction<T1,T2,TResult>
, where TResult is the type of value returned by the functon. (as in, Func<T1,T2,...,TResult>
)