0

From the documentation:

[...] the Array class implements the System.Collections.Generic.IList<T>, System.Collections.Generic.ICollection<T>, and System.Collections.Generic.IEnumerable<T> generic interfaces. The implementations are provided to arrays at run time, and therefore are not visible to the documentation build tools.

Is this available to c# developers. I mean can I provide run time implementation to any interface on a class?

1 Answers1

2

Yes, arrays are special and behave exactly as linked documentation says.

No, you can't add arbitrary (or even specific) interfaces to classes at run-time unless you are creating your own implementation of CLR.

Note that there are many ways to mimic behavior of adding interfaces like extension methods or wrapping objects with proxy classes but there is no true way to add interface to a class dynamically.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179