How to TryParse for Enum value?

前端 未结 14 1002
终归单人心
终归单人心 2020-11-29 00:22

I want to write a function which can validate a given value (passed as a string) against possible values of an enum. In the case of a match, it should return th

14条回答
  •  醉酒成梦
    2020-11-29 00:33

    The only way to avoid exception handling is to use the GetNames() method, and we all know that exceptions shouldn't be abused for common application logic :)

提交回复
热议问题