Application settings enable you to store and retrieve property settings and other information for your application dynamically. They also enable you to maintain custom application and user preferences on the client computer. Often this is data (such as a connection string) that is critical to running the application and that you do not want to include directly in the application's code. You might want to store two different database connection strings and retrieve one of them at run time based on the computer's location. Or you might want to store a user's color preferences and then retrieve them the next time that the application runs.
Note that application settings are a Visual Studio feature that replaces the dynamic properties feature in earlier versions (For information about dynamic properties, see Configuring Applications Using Dynamic Properties.)
Each application setting must have a unique name. The name can be any combination of letters, numbers, or an underscore that does not start with a number, and it cannot contain spaces. The name can be changed through the Name property.
Application settings can be stored as any data type that is XML serializable or has a TypeConverter that implements ToString/FromString. The most common types are String, Integer, and Boolean, but you can also store values as Color, Object, or as a connection string.
Application settings also contain a value. The value is set with the Value property and must match the data type of the setting.
In addition, application settings can be bound to a property of a form or control at design time. For more information, see How to: Add or Remove Application Settings.
There are two types of application settings, based on scope:
Application-scoped settings can be used for information such as a URL for a Web service or a database connection string. These values are associated with the application. Therefore, users cannot change them at run time.
User-scoped settings can be used for information such as persisting the last position of a form or a font preference. Users can change these values at run time.
You can change the type of a setting by using the Scope property.
The project system stores application settings in two XML files: an app.config file, which is created at design time when you create the first application setting; and a user.config file, which is created at run time when the user who runs the application changes the value of any user setting. Notice that changes in user settings are not written to disk unless the application specifically calls a method to do this.