How to TryParse for Enum value?

前端 未结 14 1006
终归单人心
终归单人心 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:30

    I have an optimised implementation you could use in UnconstrainedMelody. Effectively it's just caching the list of names, but it's doing so in a nice, strongly typed, generically constrained way :)

提交回复
热议问题