In .Net is the 'Staticness' of a public static variable limited to an AppDomain or the whole process? -
is 1 copy of public static variable created each appdomain in process or 1 copy whole process? in other words if change value of static variable within 1 appdomain, affect value of same static variable within appdomain in same process?
it per application domain proven example:
public class foo { public static string bar { get; set; } } public class test { public test() { console.writeline("second appdomain: {0}", foo.bar); } } class program { static void main() { // set value in main appdomain foo.bar = "bar"; console.writeline("main appdomain: {0}", foo.bar); // create second domain var domain = appdomain.createdomain("secondappdomain"); // instantiate test class in second domain // constructor of test class print value // of foo.bar inside second domain , null domain.createinstance(assembly.getexecutingassembly().fullname, "test"); } }
Comments
Post a Comment