Obtaining a class' fully qualified name

A

Aashish Patil

Hello,

Is it possible to obtain the fully qualified name of a
class in c#. What I am looking for is something analogous
to Box.class.getName() that exists in Java.

Its possible to get this by calling GetType() on an
instance but I need to do this in a static method of the
same object whose fully qualified name is needed. Thus,
there is no instance available on which the GetType()
method can be called.

Currently, I am hard-coding (in a variable) the fully
qualified name but that does not sound like an elegant
solution.

Thanks
Aashish
 
M

Mattias Sjögren

Is it possible to obtain the fully qualified name of a
class in c#. What I am looking for is something analogous
to Box.class.getName() that exists in Java.

typeof(Box).FullName



Mattias
 
J

Jon Skeet [C# MVP]

Aashish Patil said:
Is it possible to obtain the fully qualified name of a
class in c#. What I am looking for is something analogous
to Box.class.getName() that exists in Java.

typeof(Box).FullName
 

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