• 首先说下 IsGenericType
    用3个实例说明:
   typeof(DateTime).IsGenericType : false
   typeof(List<int>).IsGenericType: true
   typeof(Dictionary<,>).IsGenericType:true

类型如果是泛型则为 true
但是要注意以下情况:
T[], List[] 等等数组时, IsGenericType为 False
typeof(T[]).GetElementType().IsGenericType才是 True

  • 接着说 IsGenericTypeDefinition
    用2个实例说明:
   typeof(List<int>).IsGenericTypeDefintion : false
   typeof(List<>).IsGenericTypeDefinition :true

IsGenericTypeDefinition : 获取一个值,该值指示当前 Type 是否表示可以用来构造其他泛型类型的泛型类型定义。
也就是说表明 这个 type 是否可以用于构建泛型定义
比如 List<> 可以通过反射构建出 List,List
例子:

var typeList = typeof(List<>);        
Type typeDataList = typeList.MakeGenericType( typeof(DateTime)); //通过List<>构建出List<DateTime>
  • 最后说下 IsGenericParameter
    这个Property用于表明当前类型是一个T类型
    例如:
    typeof(List<>).GetGenericArguments()
返回: new Type[]{ typeof(T) }
        typeof(T).IsGenericParameter == True
        typeof(T).GenericParameterPosition  == 0    
 typeof(List<DateTime>).GetGenericArguments()
返回: new Type[]{ typeof(DateTime) }
    typeof(DateTime).IsGenericParameter  == False
    typeof(DateTime).GenericParameterPosition    : throw exception
首先说下 IsGenericType 用3个实例说明: typeof(DateTime).IsGenericType : false typeof(List).IsGenericType: true typeof(Dictionary<,>).IsGenericType:true 类型如果是泛型则为 true接着说 IsGenericTypeDefinition 用2 大于或小于0的数字为真 对象只是强制转换为布尔值( !! ),它适用于null (因为 type of null === "object" ) 字符串将转换为小写并与"true"或"1" Symbol目前被视为永远为真 未定义始终为假 如果这些类型都不与传递的项目匹配,则抛出 Type Error 。 使用非常简单: var to Bool = require("to- bool "); if (to Bool (someVariable)) { console.log("It's true.");
IsGenericType tells you that this instance of System. Type represents a generic type with all its type parameter s specified. For example, List<int> is a generic type . IsGenericType Def init ion , on the other hand, tells you that this instance of System.
type of(DateTime). IsGenericType : false type of(Listint>). IsGenericType : true type of(Dict ion ary). IsGenericType :true123123 类型如果是 泛型 则为 true  但是要注意以下情况:  T[], List 值只有True和False两种情况 所有的数据类型经过: bool (数据)转换后,都只有True和False两种情况,那究竟什么时候为True,什么时候为False呢?我们用代码来说明情况: 对于int类型: a = 10 print( type ( bool (a))) print( bool (a)) <class ' bool '> b = 0 print( type ( bool (b))) print( bool (b)) Console.WriteLine( type of(DoubleList).Base Type .GetGenericArguments()[0]. IsGenericType Def init ion ); 你能做出来吗? if (property Type . IsGenericType && property Type .GetGeneric TypeDef init ion () == type of(Nullable<>)) property Type = pr...