从Reflection/CodeDom/CLR发送的类名称中的"1"是什么?

Chr*_*all 0 .net c# generics clr types

我不记得确切地在哪里看到了这个奇怪的`1(单一刻度和数字1)出现在类名旁边,但它在调试时检查变量值并且最近在这个问题的答案中显示出来.

targetClass.BaseTypes.Add(new CodeTypeReference { BaseType = "DataObjectBase`1[Refund]", Options = CodeTypeReferenceOptions.GenericTypeParameter })
Run Code Online (Sandbox Code Playgroud)

我很好奇:这是从哪里来的,为什么会出现?

Meh*_*ari 6

它是具有1个类型参数的泛型类型.

例如,List<T>

System.Collections.Generic.List`1
Run Code Online (Sandbox Code Playgroud)

并且Dictionary<TKey, TValue>

System.Collections.Generic.Dictionary`2
Run Code Online (Sandbox Code Playgroud)

这允许泛型类型由类型参数的数量重载.