Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How Delphi Converts String Type into Enumeration Type
How Delphi Converts String Type into Enumeration Type
The following code is to convert an enumeration into a string, and vice versa.

Use GetEnumName to determine whether the input strings match, and then return the enumeration value.

use

TypInfo

type

TTest = (a, b, c, d, haha, yeah);

Program TForm 1. Button 1Click (sender: toobject);

defined variable

ti:PTypeInfo;

TD:PTypeData;

I: integer;

begin

ti:= type info(TTest);

TD:= GetTypeData(ti);

Because I: = MinValueMaxValue do of TD. TD.

List box 1. Items.Add(GetEnumName(ti,I));

End;