in a cs file I have a IF function like this>
If (myValue == 'AA' || myValue == 'BB' || myValue == 'CC')
{
DoThis()
}
But now and then I have to add some more conditions: myValue == ‘DD’ and so on.
Is not possible insert the new values (and All values)
in the web.config
and read from there instead of modify the code?
For example, in my web.config file I can have something like this:
<appSettings>
<add key="AA" value="AA"/>
<add key="BB" value="BB"/>
<add key="CC" value="CC"/>
<add key="DD" value="DD"/>
</appSettings>
and in the code I should have something like:
IF mySearchString is present in the list from web.config, THEN call DoThis() method
Thank you in advance.
Luis
2
Answers
First create a key in web.config with comma separated value as below.
Then access the variable and split it.
try this
or you can iterate using Linq or foreach