Home All Groups Group Topic Archive Search About

how to get the namespace inside a static method?

Author
20 Nov 2006 12:15 PM
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

Author
20 Nov 2006 12:44 PM
Ciaran O''Donnell
static string GetNamespace(){
    return new
System.Diagnostics.StackTrace().GetFrame(0).GetMethod().DeclaringType.Namespace;
}

Try the above

Ciaran O'Donnell

Show quote
"Kevin" wrote:

> Hi there,
>
> I have a class with a static method, how can I find the namespace of the
>   class from inside the method.
>
> TIA
>
Author
20 Nov 2006 4:05 PM
Kevin
^_^

Works great, thanks Ciaran.

Ciaran O''Donnell wrote:
Show quote
> static string GetNamespace(){
>     return new
> System.Diagnostics.StackTrace().GetFrame(0).GetMethod().DeclaringType.Namespace;
> }
>
> Try the above
>
> Ciaran O'Donnell
>
> "Kevin" wrote:
>
>> Hi there,
>>
>> I have a class with a static method, how can I find the namespace of the
>>   class from inside the method.
>>
>> TIA
>>

AddThis Social Bookmark Button