Using the typeof operator. string s = typeof(MyClass).Name;
-----Original Message----- From: Erick Thompson [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 25, 2002 2:19 PM To: [EMAIL PROTECTED] Subject: Re: [DOTNET] Method call in parameter? Never mind, I just realized I was in a static method, so neither this nor GetType() works. How do I get the name of class I'm currently executing in if I'm in a static method? Erick ----- Original Message ----- From: "Erick Thompson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, April 25, 2002 2:13 PM Subject: [DOTNET] Method call in parameter? > I have a static method with the following signature > > internal static void LogError(string description, string className) > > when I call it from a catch block with the following > > } catch (Exception ex) { > Util.ErrorLogging.LogError(ex.ToString(), this.GetType().Name); > > I get a compile time error "Keyword this is not valid in a static property, > static method, or static field initializer". I had always assumed that this > was a valid way to pass in arguments. Can anyone tell me why this shouldn't > work? > > Thanks, > Erick > > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.