Is there a way (reflection or otherwise) to programatically determine that the IList interface requires ICollection, which in turn requires IEnumerable?
I'm working on a reflection library and came across a scenario where I could use this information, but found no way to obtain it. Both the compiler and the IDE (obviously) know the relation, so it must be available somehow.
I'm hoping for suggestions that don't involve IL or source parsing, neither of which really is an option for my use case.
You can use Type.GetInterfaces
to discover this information.
Examples below in powershell:
PS C:\> [collections.ilist].getinterfaces()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False ICollection
True False IEnumerable
The equivalent in c# would be: typeof(IList).GetInterfaces()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With