In my code I’m dealing with ObservableCollections (as a System.Type). Then I do :
var args = propertyType.GetGenericArguments();
to know what type of Collection I have I’m doing tests like :
if (args.Count() != 0 && args[0] == typeof(string))
I’m testing if args is not empty but what Im wodering is “Is it possible that the args list is empty when I’m dealing with ObservableCollection ?”
Im not sure if what Im asking is clear, just tell me if it’s not !
No. args can never be empty if the propertyType is a generic type.
You can rather check if the type is generic before executing this code using
type.IsGenericTypeproperty.Hence I would suggest it this way: