Does T [] use IList <T>?

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

When creating a new instance of the class, I can pass IElement[]instead IList<IElement>how is this possible?

+4
source share
1 answer

An array with an element type Tcomes from IList<T>.

It does not appear in the metadata in mscorlib.dll, but an inheritance relationship is created at runtime in the common language runtime. C # and the CLR know the type of array and consider it on purpose.

+10
source

Source: https://habr.com/ru/post/1531585/


All Articles