Why do generics often use T?

前端 未结 8 871
故里飘歌
故里飘歌 2020-12-17 18:08

Is there any reason for the use of \'T\' in generics? Is it some kind of abbreviation? As far as I know, everything works. For example

public G Say         


        
8条回答
  •  -上瘾入骨i
    2020-12-17 18:23

    T is for Type. But it's really just a tradition and there is nothing to prevent you from using other names. For example, generic dictionaries use .

    There is also a Microsoft guideline that recommends using the letter T if you have a single type parameter, and prefix descriptive parameter names with T if you have more than one. Doing so will provide a more consistent feel across your code.

提交回复
热议问题