4

When I press Ctrl and click on List in VS2010, List'1.cs file is opened, and the file contains the method headers and the summary comments,

enter image description here

The question is, why thy didn't name that file List(T).cs or List{T}.cs or List[T].cs? Why the naming convention List'1.cs, is that standard?

HB MAAM
  • 3,913
  • 4
  • 29
  • 39

3 Answers3

3

Found in the specification Section 10.7.2 Type names and arity coding (the quote is a little malformed):

CLS-compliant generic type names are encoded using the format ―name[arity]‖ , where […] indicates that the grave accent character ―‖ and arity together are optional. The encoded name shall follow these rules:

  1. name shall be an ID (see Partition II) that does not contain the ―`‖ character.
  2. arity is specified as an unsigned decimal number without leading zeros or spaces.
  3. For a normal generic type, arity is the number of type parameters declared on the type.
  4. For a nested generic type, arity is the number of newly introduced type parameters.

If you couple this with the <> characters not being valid for Windows file names, it makes some sense why they applied the naming convention to the file name as well. The ` symbol is a valid Windows file name character.

Adam Houldsworth
  • 63,413
  • 11
  • 150
  • 187
3

In the CLR, that's the default way to annotate generic types. List`1 means that this class has one generic type parameter. The brackets are just a C# thing, also they are not valid as file names.

Botz3000
  • 39,020
  • 8
  • 103
  • 127
1

The naming is standard for generic types.

BitKFu
  • 3,649
  • 3
  • 28
  • 43