Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Instantiate a class and assign it to an interface variable

$
0
0

http://stackoverflow.com/questions/1176416/implementing-ilist-interface

I as looking at the implementation of the IList interface using the above linke. The private member of the class has been declared as

        private readonly IList<T> _list = new List<T>();
I don't quite understand how we can instantiate a class List<T> and assign it to an interface variable _list.My understanding was that an interface was a contract of methods that need to be implemented when a class derives from it. What exactly is happening here? It compiles without problems.

 





Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>