.net - ASP.NET Application variable vs reading from ConfigurationSettings.AppSettings -


there similar question posted @ application variable vs web.config variable, mine different , i'm not convinced answer there.

so, if define application variable in global.asax this:

public class global : system.web.httpapplication {        public static readonly string x =  configurationsettings.appsettings["xsltexternal"];    // rest of code here } 

shouldn't read operation

string y = global.x; 

be faster than

string y = configurationsettings.appsettings["xsltexternal"]; 

because of avoiding hashtable lookup (presuming that's how asp.net stores web.config settings)? application uses tons of config settings , checks throughout page cycle i'm hoping take advantage of every single ms can save.

thoughts anybody?

ps: initial simple-test-page ants profiler test shows read time dropping 0.017 ms .002 ms.

i yes, faster, try keep global class clean possible. in implementations put configuration items on separate class static constructor, example:

public class constants {     public static string paypalseller;     public static string paypalurl;     public static string paypalpdtkey;     public static string rpxtokenurl;     public static string virtualappfolder;     static constants()     {          paypalseller = configurationmanager.appsettings["paypalseller"];         paypalurl = configurationmanager.appsettings["paypalurl"];         paypalpdtkey = configurationmanager.appsettings["paypalpdtkey"];         rpxtokenurl = configurationmanager.appsettings["rpxtokenurl"];     }  } 

to use it, of course go:

constants.paypalseller 

hope helps, -covo


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -