Is there a way to check whether ParameterInfo
is a Collection?
I have tried this:
ConstructorInfo[] constructorInfos = typeof(T).GetConstructors();
ConstructorInfo constructorInfo = constructorInfos[0];
ParameterInfo[] paramsVar = constructorInfo.GetParameters();
IEnumerable<ParameterInfo> collectionParams = paramsVar.Where(
x => x.ParameterType.GetElementType() is ICollection);
but it does not work. Any ideas?
Try this:
(note that I've removed the
GetElementType
call and switchedtypeof(ICollection)
andx.ParameterType
)