可能重复:
C# 语言:泛型、打开/关闭、绑定/未绑定、构造
在 C# 中使用反射做一些事情时,我注意到某些类型具有类型定义,例如
Foo<,>
这个符号的官方术语是什么?
Type names which are missing generic parameters such as List<>
are referred to as unbound generic types. This question has a good summary of unbound generic types as well as some related terminology.
Depending on what context you are describing these types, some other terminology may be used. The C# specification uses the term "unbound generic type" to refer to something like T<>
. The .Net framework seems to prefer the terms "generic type definition" (as dasblinkenlight pointed out, see also Type.GetGenericTypeDefinition()
) or "open generic type" (see this article).
This is a type that represents a generic type definition:
var genType = typeof(Foo<int,int>);
var genTypeDef = genType.GetGenericTypeDefinition(); // Returns typeof(Foo<,>)