Re: Generics and type names.
I'm not sure what you're trying to accomplish. What do you mean by correct type? A string is a string
If you want to figure out what type something is, wouldn't typeof be better?
Re: Generics and type names.
The following "does the work" (it is a snippet pulled from working code, it will NOT compile on its own
Code:
if (type.IsGenericType && !type.IsGenericTypeDefinition)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat(typeName.Substring(0, typeName.IndexOf('`')));
sb.Append("<");
bool first = true;
foreach (Type genericArgumentType in type.GetGenericArguments())
{
if (!first)
sb.Append(", ");
first = false;
sb.Append(GetTypeName(genericArgumentType));
}
sb.Append(">");
typeName = sb.ToString();
}
Re: Generics and type names.
ahh.. I didn't see GetGenericArguments method.
Thank you.