If you want to use it for strings, you can take several alternatives:
Use TStringList. Let's start with one alternative string after another, shall we? Add it in and call its IndexOf method;
If the nth character (n should be a constant) of your alternatives is different from each other, then you can uniquely identify your string by taking out this character;
First, all alternatives are declared as an enumeration value, and then we can use the case statement as long as we convert the string we are looking for into an enumeration. For example: type tmystrsel = (Beijing, Tianjin, Shanghai, Chongqing). However, if you choose a variable name naming rule that does not conform to Delphi (such as' AK-47' or Chinese). ), cannot be declared as an enumeration type, and cannot use this method.