docs
docs copied to clipboard
Bad example
The naming used in the following example from this page makes it confusing to understand.
public class Generic<T> { public T Field; }
The topic is generics, but naming the sample class "Generic" is confusing. Some may interpret it to mean that all generic classes must be named "Generic".
Instead, much clearer is to use arbitrary names such as:
public class foo<T> { public T bar; }
or something like:
public class myFileReader<T> { public T readLine; }
Sincerely Phil
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 0fc82239-30f3-14d2-ed23-5c0b66bd370e
- Version Independent ID: 26fccd46-c489-1a05-2da2-dda3a8e5fac8
- Content: Generics in .NET
- Content Source: docs/standard/generics/index.md
- Product: dotnet-fundamentals
- GitHub Login: @adegeo
- Microsoft Alias: adegeo
@pshisbey I agree Generic
is unnecessarily ambiguous. foo
and bar
are specifically forbidden. myFileReader
is too specific. I think the following would be better:
public class MyGeneric<T>
{
public T MyField;
}
@gewarren I would like to work on this - please assign me so I have it on my list.