Delphi XE8 Create结构体
Delphi xe8的结构体支持 Create ,但是不支持 free,挺棒的。
type TValuePair = record Name: string; Value: string; constructor Create(const AName, AValue: string); end; implementation {$R *.dfm} constructor TValuePair.Create(const AName, AValue: string); begin Name := AName; Value := AValue; end; procedure TForm1.Button3Click(Sender: TObject); var m_ValuePair: TValuePair; begin m_ValuePair := TValuePair.Create('姓名', '张三'); Memo1.Lines.Add(m_ValuePair.Name + ' --- ' + m_ValuePair.Value); //FreeAndNil( m_ValuePair ); //报错 ,不支持free end;