When reading code, how do you say the following statement? (It was taken from some C# code, could be many languages, though).
List<string>
Do you say:
List of type string?
or
List of string
or
List of string type
or
Something else
The common way is to say list of string.
It comes from the mathematical convention of pronouncing the notation of a function: f(x) is read as "f of x". The convention is as universal as mathematics, so every human language will have a local way of saying it.
Even if generics are not functions, they are a parameterized types. So instead of applying a function to an argument between (...)
, you apply a generic definition to a type argument between <...>
. So by analogy, the same wording is used.
Sometimes, in case of ambiguity, the longer list of type string is used. But IMHO the longer form is used only if there would be a risk of confusion with a function parameter. Typically, when using C++ template function rather than template class.
Just as any other list of things, a list that consists of a certain type of objects, say holiday locations, is called a 'list of [object]s', e.g. a list of locations. So in your example a list of strings.
The functional perspective suggested by Christophe is possible as well, and might be more dominant around syntax/math oriented programmers. Typically the 'normal' way (list of strings) dominates when talking about actual instances, whereas the functional version (list of (type) string) might more likely dominate when strictly speaking about the type.
Mug<T>
on it. If it isn't said as "mug of T" then my rubbish geek joke fails, so I definitely vote for saying it as "list of string".List(Of String)
(which supports @Christoph's answer).