String to enum conversion in C#

后端 未结 8 2124
孤街浪徒
孤街浪徒 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:12

    You can use the Parse method:

     Operarion operation = (Operation)Enum.Parse(typeof(Operation), "Not_Equals");
    

    Some examples here

提交回复
热议问题