Sometimes we need to use the constants in different parts of our project. We can simply use constant values. But what if after a span of time (months or years) the constant value changes? Then the programmer need to change the constant value on every place where he had used the constant.
One solution to this problem is to set the value of constant in web.config file in the <appSettings> tag.
Then we can access this value at code file wherever we require.Let me explain it with example.
Put the following code inside your web.config file:-
Now to access this values inside the code file write the following code:-
Now wherever you use the value1 and value2 values will be changed whenever you change the value attribute of the key inside <appSettings> tag of the web.config file. You can place the keys and values in separate file and reference it in web.config file Click Here for code.