Foreach List with unknown item type
<p>I need to go through List. I do not know in advance what type of element List contains the List I get as an object.</p>

<pre><code>void anyMethod(object listData, Func&lt;object, string&gt; callback)
{
    foreach (object item in (List&lt;object&gt;)data)
    {
        string value = callback(item);
        doSomething(value)
    }
};
...
List&lt;MyObject&gt; myList = something();
anyMethod(myList, obj =&gt; (MyObject)obj.Name)
...
List&lt;AnotherObject&gt; myList = somethingAnother();
anyMethod(myList, obj =&gt; (AnotherObject)obj.foo + (AnotherObject)obj.bar)
...
</code></pre>

<p>I need something he does as DropDownList when the process DataSource.
Thanks for your help.</p>
