chkaufmann 17 Posted December 2, 2020 For many enumeration type I have I define the same set of methods. Here is an example: TBSSwGender = (sgeNone, sgeMen, sgeWomen, sgeMixed); TBSSwGenderHelper = record helper for TBSSwGender public function AsInteger: Integer; function Code: String; function Name: String; end; function TBSSwGenderHelper.AsInteger: Integer; begin Result := Ord(Self); end; function TBSSwGenderHelper.Code: String; begin Result := '#Enumeration.BSSwGenderCode%d'.Fmt([AsInteger]).Translate; end; function TBSSwGenderHelper.Name: String; begin Result := '#Enumeration.BSSwGenderName%d'.Fmt([AsInteger]).Translate; end; Now my question is, instead of writing the same code for all types. So something like this: TBSEnumHelper<T> = record helper for T function AsInteger: Integer; ... end; TBSEnumHelper<TBSSwGender> = record helper for TBSSwGender Christian Share this post Link to post
David Heffernan 2345 Posted December 2, 2020 You can't have generic helpers. Share this post Link to post