Get generic type fullname without assembly version,culture and PublicKeyToken

Z

zlf

I want to get type name as
System.Collections.Generic.IList`1[[System.String, mscorlib]] for
typeof(IList<string>).
But for now, the closest result I can get is
System.Collections.Generic.IList`1[[System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] by
calling typeof(IList<string>).FullName. I do not want assembly
version,culture and PublicKeyToken.

Thanks

zlf
 
M

Marc Gravell

Well, you could build it up from scratch using reflection,
GetGenericArguments(), FullName, getting the assembly, etc - but I
wonder if a regex isn't easier in this case...

s = Regex.Replace(s, @"(\[[^,]*?,\s*[^,]*?)(,[^\]]*?)(\])", "$1$3");

Marc
 

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