Wednesday, October 5, 2011

Settings in C#

The .NET Framework 2.0 allows you to create and access values that are persisted between application execution sessions. These values are called settings.

Suppose we have this setting in <AssemblyName>.exe.config file associated with your application
<setting name="MyTest" serializeAs="String"> <value>0</value>
</setting>



Value of this setting can be retrieved at runtime using following code:

string sTest= Properties.Settings.Default.MyTest;



To update value in setting use following:

Properties.Settings set = Properties.Settings.Default;

set.MyTest = "Test123";



No comments:

Post a Comment

How to upload app to macOS

1. Open Terminal Press Cmd (⌘) + Space , type Terminal , and hit Enter . 2. Navigate to Your Build Output Directory Your .app file is likel...