Omar Abid Omar Abid -5 years ago 165 Question

How to use settings in Visual C#

I have been a developer for a long time and changed recently to C#.
When I was using, to call user settings, I just need to create a new setting using the designer and then call it from code with the My namespace.

Here's the code


I can change or get data from it.
However in C# the My keyword doesn't work, so what can I do to call settings??

Answer Source

Settings are stored under the Application folder and as such, use that as their namespace.

int myInt = Properties.Settings.Default.myVariable;
Properties.Settings.Default.myVariable = 12;

Using Settings in C#

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download