C# Downcasting Lists to IList "special tactics"
<p>So I'm working at a company and I'm relatively new here but I've come across something very strange in some production code which I'm told are written by someone much more knowledgable in C# than myself who "does things a special way".  So I'm trying to think of reasons to do what I'm about to explain, giving the benefit of the doubt but I can't come up with anything.</p>

<p><code>IList&lt;Facility&gt; Facilities = new List&lt;Facility&gt;();</code></p>

<p>The above line is at the core of the problem... the other oddities all throughout the code come from being unable to use interfaces for some things and therefore the data has to be copied back out into a List before using them (for example exporting via webservice, does not allow using an interface, must be an implementation of IList)</p>

<p>Now I understand interfaces are wonderful in the sense that you can write methods which expect the methods presribed in the interface to exist on the implementation which is being passed to your method but...</p>

<p>Can someone please help me out here...  can anyone think of a reason you'd immediately downcast a List back to its interface in the data layer of an application?</p>

<p>Also just to make it clear...  these lists are not used for interchangeable data types either, this occurs at the point where the List is defined and stored, and there is an IList per datatype which is stored.</p>

<p>Thanks!</p>
