tengo una pieza de código donde tengo que averiguar si un determinado tipo implementa IEnumerable<T>
(no me importa acerca de la T)F # equivalente de la C# typeof (IEnumerable <>)
he intentado (t:System.Type
en caso de que se preguntan)
let interfaces = t.GetInterfaces()
let enumerbale =
interfaces.Any(fun t ->
t.GetGenericTypeDefinition() = typeof<IEnumerable<>>
)
sin embargo, que no se compilará (la compilación no le gusta la <>). Luego intenté
let interfaces = t.GetInterfaces()
let enumerbale =
interfaces.Any(fun t ->
t.GetGenericTypeDefinition() = typeof<IEnumerable<'a>>
)
pero aparece una advertencia de que 'a es una restricción obj. No quiero averiguar si se implementó IEnumerable<obj>
pero IEnumerabl<>
.
Cualquiera sabe la solución y por cierto no dude en comentar el código anterior también.
http://stackoverflow.com/questions/1652050/generic-type-definition- syntax-on-f –