Friday, January 23, 2015

Get enum values from web.config at run time

<configuration> 
  <appSettings>
    <add key="serialParity" value="None" />  
  </appSettings>
</configuration>

string serialParityTmp = ConfigurationManager.AppSettings["serialParity"];
Parity serialParity = (Parity) Enum.Parse(typeof(Parity), serialParityTmp );

No comments: