How can I get the type (it’s name as a string) of:
1) an unassigned member?
2) the current class (I mean the one in scope) when no instance is available and without using a shared method?
EDIT: Come to think of I, I’m starting to think 1) is impossible.
EDIT: 2) may in fact never occur as such. Actually I meant the parent class of a nested class when no instance of the parent class is available (but an unassigned variable is) and without using a shared method of the parent class
If you don’t have an instance then within a method you can call
System.Reflection.MethodBase.GetCurrentMethod().DeclaringTypeEDIT
Okay, based on your edits it looks like you’ve got this:
I think this method will do what you want. Usually “null is null” and doesn’t have a type. But the method below cheats (kind of) by forcing the compiler to infer the type through generics.
Then you can call this like: