65.9K
CodeProject is changing. Read more.
Home

How to get FullType From AssemblyQualifiedName (remove Version, Culture and PublicKeyToken)

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.60/5 (4 votes)

Oct 7, 2010

CPOL
viewsIcon

20251

When this code ends, you'll get "System.String, mscorlib" instead of "System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" string typename = obj.GetType().AssemblyQualifiedName; typename = Regex.Replace(typename, @", Version=\d+.\d+.\d+.\d+",string.Empty); typename = Regex.Replace(typename, @", Culture=\w+", string.Empty); typename = Regex.Replace(typename, @", PublicKeyToken=\w+", string.Empty);