I got a Type whose FullName is (if this helps) :
"System.Collections.ObjectModel.ObservableCollection`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
From that Type, I’d like to get "System.Collections.ObjectModel.ObservableCollection" as a string but I’d like to do it “cleanly”, which means, without spliting the string with the char '`'.
I think the strategy is to get something like a Type or something else whose FullName will be "System.Collections.ObjectModel.ObservableCollection" but I really don’t manage to do it :/
The “real” type name is not
System.Collections.ObjectModel.ObservableCollection, it’sSystem.Collections.ObjectModel.ObservableCollection`1, as VirtualBlackFox correctly mentions (because it’s a generic type,`1indicates the number of generic parameters).You can get quite close by using
type.Name(givesObservableCollection`1) andtype.Namespace(givesSystem.Collections.ObjectModel).Not that your type is most probably not the generic type, but its specification with generic parameter =
string.You can get the parameter type(s) (
stringin your case) by usingtype.GetGenericArguments().