String to enum conversion in C#

后端 未结 8 2113
孤街浪徒
孤街浪徒 2020-12-03 00:52

I have a combo box where I am displaying some entries like:

Equals
Not Equals 
Less Than
Greater Than

Notice that these strings contain spa

8条回答
  •  被撕碎了的回忆
    2020-12-03 01:11

    I would use a singleton of this enum mapper class that performs much faster than Enum.Parse (which uses reflection and is really slow). You can then use EnumFromString(typeof(YourEnum), "stringValue") to get your enum.

提交回复
热议问题