I have a C# class definition with some static members, and in the static methods I want to pass the class name to a log event method to indicate which class the log event came from. I cannot use this.GetType().Name
because there is no "this" in a static method.
public class Settings
{
static public void Foo()
{
LogEvent(this.GetType().Name, "I'm in Foo");
}
}
This code won't compile because in a static method there is no "this".
Question is: How to access (using reflection) the static member's class name during runtime?
Aucun commentaire:
Enregistrer un commentaire