有个需求,需要递归遍历类型的所有属性(属性的属性),然后对不同的类型做不同的处理,或者只是将类型分为三类:Primitive、Complex 和 Collection。因为 MS 的 Type 提供了 IsPrimitive 属性,这里重点说下我对 Primitive 的期望,原本以为肯定要包含:Decimal,有可能包含:String,可是并非如此。

Type.IsPrimitive Property

官方地址:http://msdn.microsoft.com/en-us/library/system.type.isprimitive(v=vs.110).aspx

The primitive types are BooleanByteSByteInt16UInt16Int32UInt32Int64UInt64IntPtrUIntPtrCharDouble, and Single.

If the current Type represents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.

 

相关文章:

  • 2021-07-17
  • 2021-04-17
  • 2021-11-03
  • 2021-11-15
  • 2022-02-23
  • 2022-12-23
  • 2021-07-01
  • 2021-10-28
猜你喜欢
  • 2022-02-14
  • 2022-12-23
  • 2021-06-23
  • 2021-08-31
  • 2021-07-30
  • 2021-10-20
  • 2022-12-23
相关资源
相似解决方案