I adh some constants in my project.
private const int refercePosition = 0.3;
I shifted the constants to the Settings file of my project (i.e into App.config) and using now in my project as.
private static int refPos = Properties.Settings.Default.referencePosition;
Is this a good practice to decalre the variable as static instead of constant?
There are approximately 10 other constants in my project which which I did the same.
BTW, since App.config variables are runtime configurable but does declaring a variable as static defeat that purpose?
It is not a drop in replacement since now
refPoscan be modified during runtime. If that is your purpose that is fine, otherwisemakes
refPosreadonly during runtime. More close to the nature of aconst.You may also want to look at the singleton pattern.