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 code
My.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??
views:
1604answers:
3
A:
// Retrieving connection string from Web.config.
String connStringMSQL = WebConfigurationManager.ConnectionStrings["andi_msql"].ToString();
In my case this was for my connectionStrings setting but depending on what node your setting is in you can change this accordingly.
Hope this helps
Andi
2009-03-16 14:06:16
appologies thing i misunderstood the question
Andi
2009-03-16 14:08:39
The question mentions nothing about ASP.Net.
Samuel
2009-03-16 14:08:46
as already commented on!
Andi
2009-03-16 14:11:24
You must not be familiar with write-write conflicts. It's nothing personal.
Samuel
2009-03-16 14:13:05
+1
A:
Here is a pretty good article
http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx
Alekc
2009-03-16 14:06:46
+5
A:
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();
Samuel
2009-03-16 14:07:14
Settings in C# are very easy and nice, only part I don't like is the .config file with comes with your executable. A curious user might think that is where the settings are stored, but it's not, they are the defaults.
Samuel
2009-03-16 14:10:28