Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does T[] implement IList<T>? [duplicate]

Tags:

c#

I have a class constructor that takes a IList<IElement> as an argument.

When creating a new instance of the class I'm able to pass a IElement[] instead of the IList<IElement> how is that posible?

like image 440
eNepper Avatar asked Dec 26 '22 12:12

eNepper


1 Answers

An array with element type T derives from IList<T>.

This is not visible in the meta-data in mscorlib.dll, but the inheritance relationship is created at runtime in the CLR. C# and the CLR are aware of the array type and treat it specially.

like image 199
usr Avatar answered Jan 02 '23 19:01

usr