Get type name without full namespace

leora picture leora · Aug 3, 2010 · Viewed 164.7k times · Source

I have the following code:

return "[Inserted new " + typeof(T).ToString() + "]";

But

 typeof(T).ToString()

returns the full name including namespace

Is there anyway to just get the class name (without any namespace qualifiers?)

Answer

Tim Robinson picture Tim Robinson · Aug 3, 2010
typeof(T).Name // class name, no namespace
typeof(T).FullName // namespace and class name
typeof(T).Namespace // namespace, no class name