c# - var not getting implicit value -


i came across code below:

public void listcontrols(controlcollection controls, list<control> controlsfound) {     foreach (var control in controls)     {         if (control iattributeaccessor)         {             controlsfound.add(control); //error (invalid argument add method)             listcontrols(control.controls, controlsfound);         }     } }  

it gives error above:

if change var in foreach control works. reason add method expecting control parameter. think var should have been implicitly replaced control, right?

no, doesnt because controlcollection implements non-generic ienumerable not generic ienumerable<control> when enumerate without providing type, object


Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -