I have been a VB.net developer for a long time and changed recently to C#.
When I was using VB.net, 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 codeMy.settings.anysetting
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??
To open the Settings editor, use the following VS Code menu command: On Windows/Linux - File > Preferences > Settings. On macOS - Code > Preferences > Settings.
To change your development settings after you open Visual Studio for the first time, follow these steps: Select Tools > Import and Export Settings from the menu bar to open the Import and Export Settings Wizard. In the Import and Export Settings Wizard, select Reset all settings, and then select Next.
For instance, Visual Studio Code has a "preferences" submenu in its file menu, whereas Visual Studio has most of its options available under "Tools->Options".
In Visual Studio, from the Project menu, choose Add New Item. The Add New Item dialog box opens. In the Add New Item dialog box, select Settings File, enter a name for the file, and click Add to add a new settings file to your solution. In Solution Explorer, drag the new Settings file into the Properties folder.
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;
Properties.Settings.Default.Save();
Using Settings in C#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With