How can I distinguish TDateTime properties from Double properties with RTTI?

前端 未结 2 1214
有刺的猬
有刺的猬 2021-02-18 19:03

Using the RTTI system in Delphi 2010, is there any way to find out if a property is a TDateTime? It\'s currently treating it as a double whenever I call back asVariant and also

2条回答
  •  一生所求
    2021-02-18 19:22

    Key point here while defining type is the type directive. These two definitions are different:

    Type
      TDateTime = Double; // here p.PropertyType.Name returns Double
    
    but
    
    Type
      TDateTime = type Double; // here p.PropertyType.Name returns TDateTime
    
    or 
    
    Type
      u8 = type Byte; // here p.PropertyType.Name returns u8
    
    but
    
    Type
      u8 = Byte; // here p.PropertyType.Name returns Byte !
    

提交回复
热议问题