I have a piece of code where I need to figure out if a given type implements IEnumerable (I don't care about the T)
I've tried (t:System.Type in case you wonder)
let interfaces = t.GetInterfaces()
let enumerbale = interfaces.Any(
fun t -> (t.GetGenericTypeDefinition() = typeof<IEnumerable<>>)
however that wont compile (the compile don't like the <>). I then tried
let interfaces = t.GetInterfaces()
let enumerbale = interfaces.Any(
fun t -> (t.GetGenericTypeDefinition() = typeof<IEnumerable<'a>>)
but get's a warning that 'a is constraint to obj. I Don't want to figure out if IEnumerable is implemented but IEnumerabl<>.
Any one know's the solution and btw feel free to comment on the code above as well. It's my first non-trivial F# program