Get name of generic class without tilde
c#, fully-qualified-naming, generics
Solution
The back-tick is indicative that the class is a generic type. Probably the easiest thing is to just lop off anything from the back-tick forward:
string typeName = typeof(T).Name;
if (typeName.Contains('`')) typeName = typeName.Substring(0, typeName.IndexOf("`"));
Problem
I am trying to get the type name of `T` using this: ``` typeof(T).Name ``` The name of the class is `ConfigSettings` Instead of returning `ConfigSettings` it is returning `ConfigSettings`1`. Is there any specific reason why? How can I return the actual name without ``1`?