Search code examples
enumerablephrase

Make phrases enumerable?


I am writing a package which needs to make some customized phrases (e.g. a bunch of city names) externally accessible. (like a normal enum with name 'MyEnum', when user types in "MyEnum.", all its enumerated members will pop up to let user choose)

I tried enum a bunch of city names as follows, but of course it didn't work.

public enum City
{
Los Angeles,
Santa Francisco,
Houston,
New York
}

I also read some earlier articles about using string attributes on enum fields, but these strings can not pop up for external use.

Any helps? Thanks in advance.


Solution

  • I think its cause an error because a white space.

    Try this

    public enum City
    {
        LosAngeles,
        SantaFrancisco,
        Houston,
        NewYork
    }
    

    Here is a sample of how to use enum.