easier way of implementing the configuration settings?

sock1992

Well-known member
Joined
May 20, 2020
Messages
107
Programming Experience
Beginner
At the moment I'm having to create a variable each time (see below) to access these specific keys. Is this the best way to call the keys within the config file each time you want to use them or is there an easier way to access them ?

C#:
int pMaxLength = int.Parse(ConfigurationManager.AppSettings["pMaxLength"]);
int pMinLength = int.Parse(ConfigurationManager.AppSettings["PMinLength"]);
 
Last edited:
Don't use the <appSettings> section. Open the Settings page of the project properties and add the settings there. You can then access them via Properties.Settings.Default.PasswordMaxLength, etc. They will still be stored in the config file so you can still edit them after deployment if you want.
 
Don't use the <appSettings> section. Open the Settings page of the project properties and add the settings there. You can then access them via Properties.Settings.Default.PasswordMaxLength, etc. They will still be stored in the config file so you can still edit them after deployment if you want.
do i need to be using windows forms to use that? im creating a project where im unable to use forms
 
Last edited:
Open the Settings page of the project properties and add the settings there.
I did this in Console Application and there is a Settings tab there too. I recall now I have used it in i Console app before too, so it works also :)
 
I did this in Console Application and there is a Settings tab there too. I recall now I have used it in i Console app before too, so it works also :)
I'm a beginner so forgive me if im asking stupid questions....I should be able to see the "settings" page under "properties" in the solution explorer? all i see is "Assembly.info.cs"
 

Latest posts

Back
Top Bottom