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






3.60/5 (4 votes)
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);