Sunday, November 10, 2019

c# - Get type name without full namespace



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



typeof(T).Name // class name, no namespace
typeof(T).FullName // namespace and class name
typeof(T).Namespace // namespace, no class name

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...