how to get the namespace inside a static method?

K

Kevin

Hi there,

I have a class with a static method, how can I find the namespace of the
class from inside the method.

TIA
 
G

Guest

static string GetNamespace(){
return new
System.Diagnostics.StackTrace().GetFrame(0).GetMethod().DeclaringType.Namespace;
}

Try the above

Ciaran O'Donnell
 
K

Kevin

^_^

Works great, thanks Ciaran.
static string GetNamespace(){
return new
System.Diagnostics.StackTrace().GetFrame(0).GetMethod().DeclaringType.Namespace;
}

Try the above

Ciaran O'Donnell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top