.net Custom Configuration How to case insensitive parse an enum ConfigurationProperty

前端 未结 3 1448
醉话见心
醉话见心 2021-02-03 16:58

One of the ConfigurationProperty I have in my ConfigurationSection is an ENUM. When .net parses this enum string value from the config file, an exception will be thrown if the c

3条回答
  •  忘了有多久
    2021-02-03 17:38

    Try using this:

    Enum.Parse(enum_type, string_value, true);
    

    Last param set to true tells to ignore string casing when parsing.

提交回复
热议问题