C # Settings Usage Summary

Source: Internet
Author: User

This blog will cover the use of settings in C #.

First of all, a desktop program in the example, when we install a new software, the software will be launched after the launch of a form such as a novice guide to pop out, each time you need to close it. Of course, these software will provide functions such as no longer display. When you choose no longer to display features, these forms will no longer show up later.

For these settings, you can use some of the following methods to store, customize the XML file, the registry, and, of course, the settings file that comes with C #. It is recommended to use the settings file. The registry is not easy to use, and custom XML needs to be parsed when it is used, and can be an alternative.

Here is an example to show

Create a new WPF project,

The blue background is settings,

A setting has 4 attribute name,type,scope,value. Focusing on the scope property, the scope property has two values of application,user. The difference is that when the scope value is application, the corresponding setting cannot be modified at run time. When the scope value is user, the corresponding setting can be modified at run time.

Setting save location: When the program compiles, the value of setting is saved in the <assemblyname>.exe.config file, for example:

Using setting in your program,

            // Modify The setting value            false ;             // Save Setting Value            Properties.Settings.Default.Save ();

Here settings the relevant content is finished.

Thank you for reading, code click here to download.

C # Settings Usage Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.