Using application/user settings in C# 2.0

This is a quick post for using application or user settings in C# 2.0. I found most of the articles dealing with it in VB which is pretty easy.

All you need to access a setting called "ServerName" in Visual Basic is this line

My.Settings.ServerName="myServer"

For more information about settings you can refer to MSDN @ https://msdn2.microsoft.com/en-us/library/bc6ws923(VS.80).aspx (all samples in VB)

In C#, to access the application/user settings you need to use this line

String myserver=Properties.Settings.Default. myServer;

If you want to write to this

Properties.Settings.Default. myServer="myServer";

But take care that you can't change application settings in code. You can only change user settings. To change the application settings, you need to write your own code to open the configuration file as any xml file and modify it. I've written a simple component to do this which I'll post later this week.