<Deleetask>
<Add key = "DSN" value = "provider = Microsoft. Jet. oledb.4.0; Data Source = c: \ Inetpub \ wwwroot \ data. mdb"/>
<Add key = "my1" value = "119"/>
</Appsettings>
1. Method 1
String constring1 = system. configuration. configurationsettings. deleettings ["DSN"];
This method uses the configurationsettings. deleettings attribute (static attribute)
This is also the most commonly used method.
2. Method 2
System. configuration. appsettingsreader appreader = new system. configuration. etettingsreader ();
String constring2 = convert. tostring (appreader. getvalue ("my1", typeof (string )));
This method first creates an instance of the appsettingsreader class, and then obtains the value of the configured node using the instance method getvalue.
How fast is the two methods?
Method 1 is simple and clear in writing.
Method 2 is slightly more written. I personally think that if you read the values of multiple configuration points at a time, you can consider method 2.
Method 1 uses static attributes, and IL converts static attributes to static attributes.