I’m working on some customized authentication code based on Microsoft’s membership stuff. While looking into the Profile functionality, I looked into the ProfileBase class found in System.Web.dll v4.0.30319. There are a few class level variables that are declared as a type but then and then initialized to a null value that is cast to that type.
For example,
private static Exception s_InitializeException = (Exception) null;
private static ProfileBase s_SingletonInstance = (ProfileBase) null;
private static Hashtable s_PropertiesForCompilation = (Hashtable) null;
I don’t normally initialize variables that have a class level scope. I’m wondering if this is something I should be doing or what purpose it serves.
Thanks for any enlightenment.
You’re probably looking at the disassemblied code.
This casting is probably added by the disassembler and it didn’t exist in the source code.
You definitely don’t have to do this kind of casting in your code.